|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
If/else statement
Hi folks,
i'm trying to compile an if/else statement. just can't seem to get it to work right and i'm banging my head against a brick wall trying to resolve it! the code i'm using is: html4strict Code:
The error message i get is: Microsoft VBScript runtime error '800a01c2' Wrong number of arguments or invalid property assignment: 'Value' the more i keep looking at different pages on the web to try and find a solution the more minced my heads getting!!! Any help would be greatly appreciated. Cheers Chris. |
|
#2
|
|||
|
|||
|
Well, that is VBScript not Javascript. Which platform are you trying to make this for?
|
|
#3
|
|||
|
|||
|
yeah i know sorry i've got java on the brain just now with something else at work!!! was hurrying, meant to post in the vb section sorry! more haste less speed springs to mind!
|
|
#4
|
||||
|
||||
|
* Moved to the VB Forum *
__________________
Spreading knowledge, one newbie at a time. Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions IE7: the generation 7 browser new in a world of generation 8 browsers. Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around. |
|
#5
|
|||
|
|||
|
What are you aiming to do with getnewequipment.Fields.Item("PriceOnAsking").Value in the Else part?
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham |
|
#6
|
|||
|
|||
|
what i'm trying to achieve is for a dynamic value to be shown.
so for example if dynamic value 'a' is >0 it will show dynamic value 'a' and dynamic value 'b' otherwise it will show dynamic value 'c' i also need for dynamic value 'a' to be represented as a currency i'm just really struggling to get my head round how to do it i can get everything working ok until i start adding in this 'if/else' |
|
#7
|
|||
|
|||
|
Quote:
It's been 4 years since I used ASP, but the rules as I recall are the same for this. You have to separate the statements (transposing where the space is, between "Value getnewequipment") with either a carriage return or a ": " Last edited by Frank20 : April 17th, 2008 at 08:27 AM. |
|
#8
|
||||
|
||||
|
getnewequipment.Fields.Item("GammiesPrice").Value > 0
Why have the statement greater than zero? Is the value an interger or simply a string? And what do you mean by this? Code:
getnewequipment.Fields.Item("GammiesPrice").Value getnewequipment.Fields.Item("price + vat?").Value
|
|
#9
|
|||
|
|||
|
this is the code i have in my page, which currently shows a value on the page of £100.00 inc vat (the monetary value is whatever the value is in the database and the 'inc vat' value is either inc vat or + vat depending on the value in the database)
Code:
<%=FormatCurrency((getnewequipment.Fields.Item("Price").Value), -1, -2, -2, -2)%><%=(getnewequipment.Fields.Item("price + vat?").Value)%>
this bit of code works lovely until i try putting in the if/else bits! I'm trying to use the if/else so that if the "price" is >0 it will show the price and vat aspect as detailed in the first paragraph of this reply. If the price is 0 then i want it to insert a text statement which again varies and is held in a database field. the code for the 'else' text is: (again this works fine when not trying to put in the if/else statement) Code:
<%=(getnewequipment.Fields.Item("PriceOnAsking").Value)%>
any help on this would be appreciated guys......... |
|
#10
|
||||
|
||||
|
Try changing the code to
<% If getnewequipment.Fields.Item("GammiesPrice").Value <> "0" Then |
|
#11
|
||||
|
||||
|
--removed--
Last edited by zynder : April 18th, 2008 at 09:41 AM. Reason: double posted |
|
#12
|
|||
|
|||
|
Do you see the...
Code:
%><% To make a bad situation worse, you left their respective statements on the same line, separated now only by a gap (a space). It's good that you scrapped them; your code belongs inside of the braces not mixed in with them. But you can't leave a gap there. You have to at least put the two statements on separate lines. Last edited by Frank20 : April 18th, 2008 at 03:49 PM. |
|
#13
|
|||
|
|||
|
well a little bit of perseverance and trying to get my head round things a bit and i finally got this little old bit of code working the way i need it!!!!!
for anyone that's interested here's how the code now looks, any suggestions on how it could be tidied up, feel free! Code:
<% if (getnewequipment.Fields.Item("GammiesPrice").Value) >0 then %>
<%= FormatCurrency((getnewequipment.Fields.Item("GammiesPrice").Value), 2, -2, -2, -2)%>
<%= (getnewequipment.Fields.Item("price + vat?").Value)%>
<% else %>
<%= (getnewequipment.Fields.Item("PriceOnAsking").Value)%>
<% end if %>
thanks for all input guys |