hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Basic ASP problem
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Basic ASP problem

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-18-2005, 04:09 AM
AstarothT AstarothT is offline
Newbie
 
Join Date: Aug 2005
Location: London, UK
Posts: 10

Basic ASP problem


First of all I feel I must apologise for asking such a basic question.....

I am not the best person at asp in the world but even I could normally workout this sort of issue but I cant see the wood for the trees on this problem


Error message:
Microsoft VBScript compilation error '800a03ea'
Syntax error
/insurance/content_20.asp, line 29
elseif ave_score > 4.25 then rating_image = "rating-4+.gif"
^


Code:
<% ave_score = (company_details.Fields.Item("ave_score").Value)
If ave_score >= 4.75 then rating_image = "rating-5.gif"
elseif ave_score > 4.25 then rating_image = "rating-4+.gif"
elseif ave_score > 3.75 then rating_image = "rating-4.gif"
elseif ave_score > 3.25 then rating_image = "rating-3+.gif"
elseif ave_score > 2.75 then rating_image = "rating-3.gif"
elseif ave_score > 2.25 then rating_image = "rating-2+.gif"
elseif ave_score > 1.75 then rating_image = "rating-2.gif"
elseif ave_score > 1.25 then rating_image = "rating-1+.gif"
elseif ave_score > 0 then rating_image = "rating-1.gif"
else rating_image = "rating-0.gif"
End if
%>


As far as i am aware I can just define it as a series of > queries but incase I couldnt I have also tried defining each like as being between 2 scores and I get the identical error

Many thanks

Reply With Quote


Sponsored Links
  #2  
Old 08-18-2005, 09:22 AM
DatabaseMart DatabaseMart is offline
WHT Addict
 
Join Date: Feb 2005
Location: Galveston, TX USA
Posts: 101
AstarothT,

You missed "Then" keyword.

If ave_score >= 4.75 then rating_image = "rating-5.gif" Then
elseif ave_score > 4.25 then rating_image = "rating-4+.gif" Then
.......

__________________
winservermart.com
Dedicated Windows and MSSQL Hosting Specialist

Reply With Quote
  #3  
Old 08-18-2005, 09:29 AM
DatabaseMart DatabaseMart is offline
WHT Addict
 
Join Date: Feb 2005
Location: Galveston, TX USA
Posts: 101
Actually it's better to use "Select Case" statement.

Select Case ave_score
Case >= 4.75 rating_image = "rating-5.gif"
Case >= 4.25 ......
Case Else ....
End Select

__________________
winservermart.com
Dedicated Windows and MSSQL Hosting Specialist

Reply With Quote
Sponsored Links
  #4  
Old 08-18-2005, 09:36 AM
AstarothT AstarothT is offline
Newbie
 
Join Date: Aug 2005
Location: London, UK
Posts: 10
Many thanks both - knew it would be something simple that I missed.

Reply With Quote
  #5  
Old 08-18-2005, 02:44 PM
AstarothT AstarothT is offline
Newbie
 
Join Date: Aug 2005
Location: London, UK
Posts: 10
Ok, corrected my code to what you suggested DatabaseMart:

<% ave_scores = (company_details.Fields.Item("ave_score").Value)
Select Case ave_scores
case >= 4.75 rating_image = "rating-5.gif"
case > 4.25 rating_image = "rating-4+.gif"
case > 3.75 rating_image = "rating-4.gif"
case > 3.25 rating_image = "rating-3+.gif"
case > 2.75 rating_image = "rating-3.gif"
case > 2.25 rating_image = "rating-2+.gif"
case > 1.75 rating_image = "rating-2.gif"
case > 1.25 rating_image = "rating-1+.gif"
case > 0 rating_image = "rating-1.gif"
case else rating_image = "rating-0.gif"
End Select
%>

Error message is basically the same (though the arrow is in a different place..... not sure whats going

Microsoft VBScript compilation error '800a03ea'
Syntax error
/insurance/content_20.asp, line 30
case >= 4.75 rating_image = "rating-5.gif"
-----^

Cheers

Reply With Quote
  #6  
Old 08-18-2005, 03:39 PM
DatabaseMart DatabaseMart is offline
WHT Addict
 
Join Date: Feb 2005
Location: Galveston, TX USA
Posts: 101
AstarothT,

Sorry. It cannot work like that way. Please try this. It doesn't have any performance advantages comparing with "If ElseIf End If" statement.


Code:
	Select Case True
		Case ave_scores > 4.75 rating_image = "rating-5.gif"
		case ave_scores > 4.25 rating_image = "rating-4+.gif" 
		case ave_scores > 3.75 rating_image = "rating-4.gif" 
		case ave_scores > 3.25 rating_image = "rating-3+.gif"
		case ave_scores > 2.75 rating_image = "rating-3.gif" 
		case ave_scores > 2.25 rating_image = "rating-2+.gif"
		case ave_scores > 1.75 rating_image = "rating-2.gif" 
		case ave_scores > 1.25 rating_image = "rating-1+.gif"
		case ave_scores > 0 rating_image = "rating-1.gif"
		case else rating_image = "rating-0.gif"
	End Select

__________________
winservermart.com
Dedicated Windows and MSSQL Hosting Specialist

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
How To Deliver Products Customers Will Pay For with David Koston - HostingCon 2012 Web Hosting News 2012-07-18 10:46:16
HostingCon Preview: Q&A with David Koston of Fortuity LLC Web Hosting News 2012-07-10 12:54:20
Monday Demo: SiteLock's Website Malware Scanning Tool Blog 2012-02-20 12:56:19
Web Host SKGOLD Adds Free CloudFlare Security to Web Hosting Plans Web Hosting News 2011-12-08 19:07:03
The Lesson of the Ten, with Jeff Hardy Web Hosting News 2011-08-08 22:12:01


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?