Solved

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

Posted on 2011-09-28
2
255 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 500 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

636 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