Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2005, 03:23 PM
Authorized User
 
Join Date: Oct 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default If then Elseif systax error

I get a syntax error from this code. have tried various combinations but no go. Realize this is beginner stuff but just can't see it. Appreciate some help. Thanks

if Z_score < 1.8 then message = "Very High"
elseif (Z_score > 1.81 and Z_score =< 2.7) then message = "High"
elseif Z_score > 2.71 and Z_score =< 2.9 then message = "Possible"
else message = "Not Likely"
end if


 
Old January 29th, 2005, 04:42 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

An If ... Then .... on a single line is considered a complete If statement, that doesn't have an Else clause. Instead, move the part to its own line:
Code:
    If Z_score < 1.8 Then
      Message = "Very High"
    ElseIf (Z_score > 1.81 And Z_score <= 2.7) Then
      Message = "High"
    ElseIf Z_score > 2.71 And Z_score <= 2.9 Then
      Message = "Possible"
    Else : Message = "Not Likely"
    End If
    But better yet, use a Select Case statement like this:
Code:
    Select Case Z_score
Code:
      Case Is < 1.8
        Message = "Very High"
      Case 1.81 To 2.7
        Message = "High"
      Case 2.71 To 2.9
        Message = "Possible"
      Case Is > 2.9
        Message = "Not Likely"
    End Select
I'm not sure if this is by design, but it looks like there's a subtle bug in your code:

You compare this:

Z_score <= 2.7

and this:

Z_score > 2.71

This means that everything between 2.7 and (including) 2.71 will never cause the message to be changed....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Pardon Me by Incubus (Track 12 from the album: Make Yourself) What's This?
 
Old January 29th, 2005, 05:25 PM
Authorized User
 
Join Date: Oct 2004
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar, thanks once again. BTW, you should publish your own book because this one being used by our class is full of questionable code.

 
Old January 30th, 2005, 07:50 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I have, but they are about "classic" ASP and Dreamweaver:

http://www.wrox.com/WileyCDA/WroxTit...764555243.html
http://www.wrox.com/WileyCDA/WroxTit...764544047.html

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM
VB Error: Syntax Error or Access Violation codehappy VB How-To 7 October 3rd, 2007 05:41 PM
ElseIF dhoward VB.NET 2002/2003 Basics 4 July 5th, 2007 12:57 PM
Phile Page error, visual studio error reps BOOK: ASP.NET Website Programming Problem-Design-Solution 0 September 27th, 2003 10:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.