Avatar of James Coats
James Coats
Flag 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
Visual Basic ClassicMicrosoft AccessVBA

Avatar of undefined
Last Comment
James Coats

8/22/2022 - Mon
Rey Obrero (Capricorn1)

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
Martin Liss

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Rey Obrero (Capricorn1)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
James Coats

ASKER
Thank you both this really helps.
James Coats

ASKER
So in this case the answer is : 14? because the "intEntry = 7" is greater than 6
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
James Coats

ASKER
Sorry I see that you did answer that...