Cấu trúc lệnh:
Select Case variable
Case value 1
Statement
Case value 2
Statement
Case value 3
Statement
Case Else
Statement
End Select
Select Case variable
Case value 1
Statement
Case value 2
Statement
Case value 3
Statement
Case Else
Statement
End Select
Ví dụ
Private Sub CommandButton1_Click()
Dim Diem As Single
Dim Xeploai As String
Diem = Cells(1, 1).Value
Select Case mark
Case 0 To 20
Xeploai = “F”
Case 20 To 29
Xeploai = “E”
Case 30 To 39
Xeploai = “D”
Case 40 To 59
Xeploai = “C”
Case 60 To 79
Xeploai = “B”
Case 80 To 100
Xeploai = “A”
Case Else
Xeploai = “Loi!”
End Select
Cells(1, 2) = Xeploai
End Sub
Private Sub CommandButton1_Click()
Dim Diem As Single
Dim Xeploai As String
Diem = Cells(1, 1).Value
Select Case mark
Case 0 To 20
Xeploai = “F”
Case 20 To 29
Xeploai = “E”
Case 30 To 39
Xeploai = “D”
Case 40 To 59
Xeploai = “C”
Case 60 To 79
Xeploai = “B”
Case 80 To 100
Xeploai = “A”
Case Else
Xeploai = “Loi!”
End Select
Cells(1, 2) = Xeploai
End Sub
No comments:
Post a Comment