Click here to Skip to main content
15,303,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If condition in the VB6.0

How can i write multiple If condition for the dropdown selection for eg

I have a dropdownlist ddlState it contains 5 state with option values as 1 , 2 , 3 , 4 , 5

SO in this suppose i select the option 1 , 2 then the following message is print and if i select the 3 , 4 and 5 then something different gets print

VB
If Instr(message , "%" ) = 1 , 2 
 (
   print message
 )
elseIf Instr (message , "%" ) =  3 , 4 , 5
 (
 print another message 
 )
 Else
  msg = ""
 End If

How can i write so
Posted
Updated 22-Jul-13 1:36am
v3

You have two other answers that show how to change the 'if' statement syntax. I would suggest that you look at the "Select...case" statement, which should simplify your logic a bit.

Info on the Select statement can be found here[^].
   
Comments
CHill60 22-Jul-13 17:39pm
   
My 5 - especially as there are 5 options in the OP's post! :-)
VB
If Instr(message , "%" ) = 1 Or Instr(message , "%" ) = 2
(
    print message
)
elseIf Instr (message , "%" ) = 3 Or Instr(message , "%" ) = 4 Or Instr(message , "%" ) = 5
(
    print another message
)
Else
    msg = ""
End If
   
Comments
lalitkr 22-Jul-13 7:21am
   
Hi Thanks ,
In this a small help that can we add in place of 1 that the combobox selected value here Suppose

<select id="cmbemp">
<option value="1"><%=("This is first one ")%></option>
<option value="2"><%=("This is second one ")%></option>
<option value="3"><%=("This is third one ")%></option>
<option value="4"><%=("This is fourth one ")%></option>
<option value="5"><%=("This is fifth one ")%></option>
</select>
so how can i inculde the number in place od the selected combox option values or text
Amitava Bag (Kolkata) 22-Jul-13 8:07am
   
http://msdn.microsoft.com/en-us/library/aa240832%28v=vs.60%29.aspx

But I have a questions. You are using VB6, so how you are using the HTML?
CHill60 22-Jul-13 17:40pm
   
Looks like xml to me ... VB6 might be old, but it can still handle xml ;-)
lalitkr 24-Jul-13 6:40am
   
Hi
The following code i have in the asp page and in the vb6.0 i am calling the option values 1 , 2 , 3 script side code is in the vb6.0 and page is in the .asp page so instead of the text can i use like selected if( msg ) = 1 or 2 Then
elseIf
print ' hello ' Then
else
print ' nothing '
end If

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900