James Coats
asked on
VBA Case Problem
I failed this question on a test. I still can't figure out the answer. I don't care what the answer is I want to understand how you get the answer. Can someone please explain each step in this code.
Private Sub cmdQuestion5_Click()
Dim intEntry As Interger
intEntry = 7
Select Case intEntry
Case 1
lblBox.Caption = 1 + intEntry
Case 2
lblBox.Caption = 2 + intEntry
Case 3
lblBox.Caption = 3 + intEntry
Case 4 To 8
if intEntry > 7 Then
lblBox.Caption = 8 + intEntry
ElseIf intEntry > 6 Then
lblBox.Caption = 7 + intEntry
Else
lblBox.Caption = 6 + intEntry
Else if
Case Else
lblBox.Caption = 20
End Select
End Sub
Private Sub cmdQuestion5_Click()
Dim intEntry As Interger
intEntry = 7
Select Case intEntry
Case 1
lblBox.Caption = 1 + intEntry
Case 2
lblBox.Caption = 2 + intEntry
Case 3
lblBox.Caption = 3 + intEntry
Case 4 To 8
if intEntry > 7 Then
lblBox.Caption = 8 + intEntry
ElseIf intEntry > 6 Then
lblBox.Caption = 7 + intEntry
Else
lblBox.Caption = 6 + intEntry
Else if
Case Else
lblBox.Caption = 20
End Select
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both this really helps.
ASKER
So in this case the answer is : 14? because the "intEntry = 7" is greater than 6
ASKER
Sorry I see that you did answer that...
ElseIf intEntry > 6 Then
lblBox.Caption = 7 + intEntry
the lblBox.Caption=14
but if this is not a typo
Dim intEntry As Interger
you will get an error and the code will not execute