Lec 10 PDF
Lec 10 PDF
Lec 10 PDF
Case Else
Block of one or more VB Statements
End Select
Ex 1:
Dim grade As String
Private Sub Compute_Click( )
grade=txtgrade.Text
Select Case grade
Case "A"
result.Caption="High Distinction"
Case "A-"
result.Caption="Distinction"
Case "B"
result.Caption="Credit"
Case "C"
result.Caption="Pass"
Case Else
result.Caption="Fail"
End Select
End Sub
Dim num As Integer
num = Val(Text1.Text)
Select Case num
Case 0
Print "You have entered zero“
Case 1
Print "You have entered one"
Case 2
Print "You have entered two“
Case Else
Print "The number you entered is greater than 2"
End Select
Ex 2:
Dim mark As Single
Private Sub Compute_Click()
'Examination Marks
mark = mrk.Text
Select Case mark
Case Is >= 85
comment.Caption = "Excellence"
Case Is >= 70
comment.Caption = "Good"
Case Is >= 60
comment.Caption = "Above Average"
Case Is >= 50
comment.Caption = "Average"
Case Else
comment.Caption = "Need to work harder"
End Select
End Sub
’ is used to comment the statement in VB 6.0
Ex 3:
Dim mark As Single
Private Sub Compute_Click()
‘Examination Marks
mark = mrk.Text
Select Case mark
Case 0 to 49
comment.Caption = "Need to work harder"
Case 50 to 59
comment.Caption = "Average"
Case 60 to 69
comment.Caption = "Above Average"
Case 70 to 84
comment.Caption = "Good"
Case Else
comment.Caption = "Excellence"
End Select
End Sub
Thank You !
Next: Looping