Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now