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
James CoatsComputer Info. Sys. StudentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
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
0
Martin LissOlder than dirtCommented:
Dim intEntry As Interger ' I assume this is really Integer
  intEntry = 7

Creates an integer and sets it's value to 7.

The Case statement examines the value of intEntry and does different things depending on the value.

If it's 1, 2 or 3 it adds that amount to intEntry, so for example if intEntry were 2, the case statement would make it 9.

The Case 4 to 8 says that if the value is within that range (which it is) then add 8 to it if it's greater than 7, or add 7 to it if it's greater than 6, other wise if it's 4, 5 or 6 add 6 to it.

Finally if no other condition is met, like if the value were 9, add 20 to it.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rey Obrero (Capricorn1)Commented:
here is the corrected code

  Dim intEntry As Integer
   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
       end if
   Case Else
       lblBox.Caption = 20

   End Select
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

James CoatsComputer Info. Sys. StudentAuthor Commented:
Thank you both this really helps.
0
James CoatsComputer Info. Sys. StudentAuthor Commented:
So in this case the answer is : 14? because the "intEntry = 7" is greater than 6
0
James CoatsComputer Info. Sys. StudentAuthor Commented:
Sorry I see that you did answer that...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.