Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-28
2
Medium Priority
?
259 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:jjc9809
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 36719491
either you put several select case inside of each other:

If Line1.text = "01"  Then
  Select Case Type 
     case "01"  
        select Case VProv 
              case  "V"
                  Do something
               case " "
                  Do something
        end select ' case vprov for Type "01"
  ...
   end select ' case type
end if 

Open in new window


or you could do:

If Line1.text = "01"  Then
  Select Case Type & VProv
     case "01V"  
                  Do something
      case "01"
                  Do something
      ...
   end select  
end if 

Open in new window


hope this helps
0
 
LVL 40
ID: 36719496
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question