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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax help for if statement

Status
Not open for further replies.

mtrasp

Programmer
Jun 15, 2009
35
US
hi can i write if statement with out else in asp code is working fine but ia m not sure using if statement with out else . can we use if statement with out else i.e if --elseif--elseif--endif please help me
below is my code

array=15.16 or 15.12win7 or 15.win7 or 15.18 win7 or .......etc

i need to execute the loop when array value is 15.16 and highervalues
<%
if isnumeric(array(1)) then
If CInt(array(0)) >= 15 And Cint(array(1)) >= 16 then
<tr>
something to display
</tr>
endif

elseif If CInt(array(0)) >= 15 AndLCASE(CSTR(left(arrDigits(1),4)))= "win7" then

<tr>
something to display
</tr>

elseif CInt(array(0)) >= 15 And Cint(left(array(1),2)) >= 16 then

<tr>
something to display
</tr>

end if
%>
 
The syntax is Else If (two words)
For example:
Code:
 If condition1 Then
   ...
Else If condition2 Then
   ...
Else
   ...
End If
 
WOW my brian is elsewhere. ignore that last post of stupidity...
Code:
If condition Then
   ...
ElseIf condition Then
   ...
Else
   ...
End If

You had "ElseIf If", which is the error... Sorry about the last post [blush]
 
just an FYI - guitarzan solved the issue, but in case you didn't know...

You can write INLINE IF/ELSE statements in vbscript - that is why there wasn't an error, but instead the code wasn't executing...

Code:
...code
if myCondition then
response.write "hello"
end if
...more code

can also be written

Code:
...code
if myCondition then response.write "hello"
...more code

with an else:

Code:
if myCondition then response.write "hello" else response.write "goodbye"



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Thank you very much for your reply

can i write like this ? i.e with out Else .

If condition Then
...
ElseIf condition Then
...
ElseIf condition Then
...
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top