Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Selection

Status
Not open for further replies.

hungnguyen

Programmer
Sep 22, 2000
43
US
Hi helper,

How do you write the if/else selection in ASP code.
<% if thing = 1 then %>
Something
<%else if thing = 2 then %>
Something else
<%else if thing = 3 then %>
Do this
<%else%>
End
<%end if%>
I have a code similar to this one but it says to need the &quot;end if.&quot; I do not know the syntax of if/else selection in ASP, so please help me if you can.
Thanks
Bye
Hung C. Nguyen


 
<%
if thing = 1 then
%>
Something
<%
else
if thing = 2 then
%>
Something else
<%
else
if thing = 3 then
%>
Do this
<%
else
%>
Something More
<%
end if
end if
end if
%>

Wushutwist


Sun Certified Java 2 Programmer
 
You may use either one, depending on your conditions:
Code:
1.   if ... then
     else ...
     end if

2.   if ... then
     elseif ... then
     elseif ... then
     .
     .
     else ...
     end if

3.   if ... then ...
Remember, you must end every if with an end if, except the third method.


Choo Khor
choo.khor@intelebill.com
 
Use the SELECT statement. The following should help, butI am not 100% about the &quot;is <&quot; and &quot;X to Y&quot; syntax. It may only be supported in VB. The colon allows a single instruction to be put on the same line as the test. You can always put statements on subsequent lines.

select case myVariant
case &quot;A&quot;: 'one action here
case &quot;B&quot;, &quot;C&quot;
'one or more actions here
case &quot;D&quot; to &quot;G&quot;
'one or more actions here
case is < 4
'one or more actions here
case Null
'one or more actions here
case else
'one or more actions here
end select


Larry
Larryh@ecn.ab.ca

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top