472,787 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,787 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 3813
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. ...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.