473,383 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
3 3866
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Marquardson | last post by:
Hi, Is it possible to use expressions in CSS with if/else statements? I am trying to dynamically resize and iframe using the following CSS: <style> iframe...
10
by: clueless_google | last post by:
hello. i've been beating my head against a wall over this for too long. setting the variables 'z' or 'y' to differing numbers, the following 'if/else' code snippet works fine; however, the ...
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
8
by: Carl | last post by:
Hi, Using MS Access 2000, is it possible to run a UPDATE or INSERT SQL query using some form of conditional IF THEN ?? for example: SELECT * FROM Books IF EXISTS(Select Books.ID = 1)
92
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if...
22
by: Hrvoje Voda | last post by:
How can I use in If statement Or? for example. if (x>10 or y>10) { .... } Hrcko
4
by: Brie_Manakul | last post by:
I need to set up an if else to show different weather scripts based on the city selection they choose. Any help on this would be great. Thanks! <%@ page language="java" import="java.util.*,...
4
by: DBC User | last post by:
Is there a software pattern for using if then else? Thanks.
43
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.