Link to home
Start Free TrialLog in
Avatar of jjc9809
jjc9809

asked on

Using Case Statements inside a Case Statement all inside an IF Statement.

Hello Everyone!

Is it possible to have sweveral case statements inside a case statement all inside an If Statement.

I have an IF Statement like this:

If Line1.text = "01"  Then

Select Case Type = "01"  Case VProv = "V" Do something

I also need to Select Case Type = "01"  Case Vprov = " "   Do something.

Can this be done all inside the If Then  

I need to have multipler case statements inside a case statement all inside the IF Statement.

Am I making any sense?

jjc9809
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg 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
No problem doing it. You just have to build it carefully. Sometimes, when I see that in code revision, the programmer made it a lot more complex than it needed to be.

From what I understand in your question, you could do only one Select Case and simplify its declaration:

If Line1.Text = "01" Then

   Select Case VProv

      Case "V"
         Do something

      Case " "
         Do something else

   End Select

End If

And remember than in VB, if you fall into a case, this is the only one that will be considered. All the following ones that have the right conditions will be disregarded.