Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is there an "Else if" in VB?

Posted on 2003-11-13
10
Medium Priority
?
474 Views
Last Modified: 2010-05-01
In C++ you can do something like:


If (x =1){
//do something
}
else if(x=2){
//something else
}
else if(x=3){
//something else
}
else{
//catch all
}

Is there a VB 6 equivalent?

Thanks
0
Comment
Question by:Igiwwa
[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
  • 5
  • 4
10 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 9743971
Yes

If (x = 1) Then
'do somthing
Else
If (x = 2) Then
'somthing else
Else
If (x = 3) Then
'somthing else
Else
'catch all
End If
End If
End If

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9743979
Sure, it is called "ElseIf", but you could just as well use a Case statement (that would be Switch in C++) for that example.

Anthony
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
ID: 9743993
I believe this code matches closer to yours:

If x =1 Then
   //do something
ElseIf x=2 Then
   //something else
ElseIf x=3 Then
   //something else
Else
   //catch all
End If

Anthony
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Igiwwa
ID: 9744000
Correct me if I am wrong, but I believe the code you gave me is equivalent to:

If (x =1){
    //do something
}
else{
     if(x=2){
          //something else
     }
     else{
          if(x=3){
               //something else
          }
         else{
              //catch all
          }
      }
}

which is not quite as elegant as the C++ way.  or maybe I am being foolish/picky
0
 

Author Comment

by:Igiwwa
ID: 9744004
(My previous comment was directed to bingie)
0
 

Author Comment

by:Igiwwa
ID: 9744019
Thanks acperkins.  I seem to remember you helping me in another question as well.  You are my go-to guy.

0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9744057
>>I seem to remember you helping me in another question as well.<<
http://www.experts-exchange.com/Databases/Microsoft_SQL_Server/Q_20776495.html

Anthony
0
 

Author Comment

by:Igiwwa
ID: 9744076
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9744292
Sorry I do not do CGI.

Anthony
0
 

Author Comment

by:Igiwwa
ID: 9747925
I wish I didn't have to.  CGI/Perl is unpleasant to me.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 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