By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

if...if...else if...multi conditional statements problem

P: n/a
Hi,
I need to do multi-conditional statements like below, but this error is
displayed :
Expected 'End'
/myFilepath, line x
else response.write(arrCorpo(sparam,sdiv)) end if

I don't understand why this 'Expected 'End'' error is called!
Here is my code:
<%

sdiv=request("div")

sparam=request("param")

snat=request("nat")

%>

<%

Function loopDatas(arrayName)

nRowCount = ubound(arrayName, 2)

For n=0 to nRowCount

response.write(arrayName(1,n)&"<BR>")

Next

End Function

%>
<%

if(sdiv=3) then

if snat="" then response.write(corpclientsmaintext)

else if (snat=1 or snat=2) then

response.write("<table
width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpclients
lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>")

call loopDatas(arrCorpoType)

response.write("</td></tr></table>")

end if

else response.write(arrCorpo(sparam,sdiv))

end if

%>

Can someone help me?

Thanks in advance

Patrice
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You have:

if(sdiv=3) then

if snat="" then response.write(corpclientsmaintext)

else if (snat=1 or snat=2) then

> end if
else response.write(arrCorpo(sparam,sdiv))

end if


If condition Then
If condition Then '''do something
Else
If condition Then
''something
End If
Else <--- ???
End If

Tab your code nicely. Don't mixup ElseIf with Else and If as two separate
words.

Ray at work


"Patrice" <ma*****@videotron.ca> wrote in message
news:le*********************@wagner.videotron.net. .. Hi,
I need to do multi-conditional statements like below, but this error is
displayed :
Expected 'End'
/myFilepath, line x
else response.write(arrCorpo(sparam,sdiv)) end if

I don't understand why this 'Expected 'End'' error is called!
Here is my code:
<%

sdiv=request("div")

sparam=request("param")

snat=request("nat")

%>

<%

Function loopDatas(arrayName)

nRowCount = ubound(arrayName, 2)

For n=0 to nRowCount

response.write(arrayName(1,n)&"<BR>")

Next

End Function

%>
<%

if(sdiv=3) then

if snat="" then response.write(corpclientsmaintext)

else if (snat=1 or snat=2) then

response.write("<table
width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpclients lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>")

call loopDatas(arrCorpoType)

response.write("</td></tr></table>")

end if

else response.write(arrCorpo(sparam,sdiv))

end if

%>

Can someone help me?

Thanks in advance

Patrice

Jul 19 '05 #2

P: n/a
Patrice,

With a bit of cleaning up, I /think/ this is what you wanted

if ( sdiv = 3 ) then
if snat="" then
response.write(corpclientsmaintext)
else
if ( snat = 1 or snat = 2 ) then
response.write( . . .
call loopDatas(arrCorpoType)
response.write("</td></tr></table>")
end if
end if
else
response.write(arrCorpo(sparam,sdiv))
end if

You've been caught out by VB[Script]'s one-line form of "If" :

If condition Then action

Written this way, there's no "End If" and you /can't/ [easily] use an
"Else" with it, either. My Advice: avoid it.

HTH,
Phill W.

"Patrice" <ma*****@videotron.ca> wrote in message
news:le*********************@wagner.videotron.net. ..
Hi,
I need to do multi-conditional statements like below, but this error is
displayed :
Expected 'End'
/myFilepath, line x
else response.write(arrCorpo(sparam,sdiv)) end if

I don't understand why this 'Expected 'End'' error is called!
Here is my code:

Jul 19 '05 #3

P: n/a
Patrice wrote on 23 mrt 2004 in microsoft.public.inetserver.asp.general:
if(sdiv=3) then

if snat="" then response.write(corpclientsmaintext)

else if (snat=1 or snat=2) then

response.write("<table
width='200'><tr><td>"&corpclientsgov&"<br>"&corpcl ientsfi&"<br>"&corpcl
ients
lcorp&"<br>"&corpclientslfirms&"<br>"&corpclientsa firms&"<br></td><td>"
)

call loopDatas(arrCorpoType)

response.write("</td></tr></table>")

end if

else response.write(arrCorpo(sparam,sdiv))

end if

You are doing this:

============================
if condition then
if condition then statement
else if condition then
statements
end if
else statement
end if
============================

This is not legal vbs code

there are two forms of if:

1 the single row:

if boolean then statement else statement

2 the multirow:

if boolean then
statement
elseif boolean then 'elsif without space
statement
else
statement
end if

in a "multi row if"
nothing can follow "then" or "else" on the same line !!!

I suppose what you want to do is:

============================
if boolean then
if boolean then statement
else
if boolean then
statements
end if
else
statement
end if
============================

but that is NOT legal either,
because now you still have an orfaned second else.

So this is legal code:

============================
if boolean then
if boolean then statement
elseif boolean then
statements
else
statement
end if
============================

btw:
booleans and the respons.write parameter do not need () in vbs:

if a=3 then

respons.write "my Text"

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.