Solved

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

Posted on 2011-09-28
2
234 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
2 Comments
 
LVL 142

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

803 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