Link to home
Start Free TrialLog in
Avatar of James Coats
James CoatsFlag for United States of America

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
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

this is where the code will be executed

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
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James Coats

ASKER

Thank you both this really helps.
So in this case the answer is : 14? because the "intEntry = 7" is greater than 6
Sorry I see that you did answer that...