473,748 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("d iv")

sparam=request( "param")

snat=request("n at")

%>

<%

Function loopDatas(array Name)

nRowCount = ubound(arrayNam e, 2)

For n=0 to nRowCount

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

Next

End Function

%>
<%

if(sdiv=3) then

if snat="" then response.write( corpclientsmain text)

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

response.write( "<table
width='200'><tr ><td>"&corpclie ntsgov&"<br>"&c orpclientsfi&"< br>"&corpclient s
lcorp&"<br>"&co rpclientslfirms &"<br>"&corpcli entsafirms&"<br ></td><td>")

call loopDatas(arrCo rpoType)

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 3890
You have:

if(sdiv=3) then

if snat="" then response.write( corpclientsmain text)

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*****@videot ron.ca> wrote in message
news:le******** *************@w agner.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("d iv")

sparam=request( "param")

snat=request("n at")

%>

<%

Function loopDatas(array Name)

nRowCount = ubound(arrayNam e, 2)

For n=0 to nRowCount

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

Next

End Function

%>
<%

if(sdiv=3) then

if snat="" then response.write( corpclientsmain text)

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

response.write( "<table
width='200'><tr ><td>"&corpclie ntsgov&"<br>"&c orpclientsfi&"< br>"&corpclient s lcorp&"<br>"&co rpclientslfirms &"<br>"&corpcli entsafirms&"<br ></td><td>")

call loopDatas(arrCo rpoType)

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( corpclientsmain text)
else
if ( snat = 1 or snat = 2 ) then
response.write( . . .
call loopDatas(arrCo rpoType)
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*****@videot ron.ca> wrote in message
news:le******** *************@w agner.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.publi c.inetserver.as p.general:
if(sdiv=3) then

if snat="" then response.write( corpclientsmain text)

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

response.write( "<table
width='200'><tr ><td>"&corpclie ntsgov&"<br>"&c orpclientsfi&"< br>"&corpcl
ients
lcorp&"<br>"&co rpclientslfirms &"<br>"&corpcli entsafirms&"<br ></td><td>"
)

call loopDatas(arrCo rpoType)

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
14167
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 {height:expression(if(document.readyState=='complete')frames("myIframe").document.body.scrollHeight+25);} </style>
10
9586
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 'case' code snippet does not. (the code's function is illustrative.) ////////////////////////////////////////// //////// working 'if/else' switch //////// //////////////////////////////////////////
3
5933
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 terminated by pressing ++ and then terminate the process. I searched the entire internet and found out that there could be two things wrong (both of them are mentioned in the bug list on the access
8
34549
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
9889
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 someone helps me... Urgent - Please reply soon ! Thanks, Raghu
22
1734
by: Hrvoje Voda | last post by:
How can I use in If statement Or? for example. if (x>10 or y>10) { .... } Hrcko
4
2316
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.*, java.text.* " %> <%@ page import="com.plumtree.remote.portlet.*" %> <%@ page import="com.plumtree.remote.prc.*" %> <% String path = request.getContextPath();
4
2385
by: DBC User | last post by:
Is there a software pattern for using if then else? Thanks.
43
7584
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. How is it possible? Please help me. Thanks in advance.
0
9552
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9326
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.