Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old April 17th, 2008, 04:09 AM
thesimpsonator thesimpsonator is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 10 thesimpsonator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
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:
Original - html4strict Code
  1. <% If getnewequipment.Fields.Item("GammiesPrice").Value > 0 Then
  2.     getnewequipment.Fields.Item("GammiesPrice").Value getnewequipment.Fields.Item("price + vat?").Value
  3.   Else
  4.     getnewequipment.Fields.Item("PriceOnAsking").Value
  5.   End If %>



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.

Reply With Quote
  #2  
Old April 17th, 2008, 04:12 AM
PHP-Newb PHP-Newb is online now
Bad Coder
Click here for more information
 
Join Date: Jul 2003
Posts: 1,592 PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level)PHP-Newb User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 15 h 55 m
Reputation Power: 123
Well, that is VBScript not Javascript. Which platform are you trying to make this for?
__________________
Under no circumstances click the button, because it is pointless. Thanks!

Reply With Quote
  #3  
Old April 17th, 2008, 04:21 AM
thesimpsonator thesimpsonator is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 10 thesimpsonator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
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!

Reply With Quote
  #4  
Old April 17th, 2008, 05:35 AM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Click here for more information.
 
Join Date: Jul 2004
Location: USA
Posts: 15,149 Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 2 Weeks 2 Days 2 h 47 m 18 sec
Reputation Power: 1294
* 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.

Reply With Quote
  #5  
Old April 17th, 2008, 05:48 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Novice (500 - 999 posts) Click here for more information
 
Join Date: Mar 2006
Posts: 609 SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level)SimonJM User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 8 m 27 sec
Reputation Power: 194
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

Reply With Quote
  #6  
Old April 17th, 2008, 05:53 AM
thesimpsonator thesimpsonator is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 10 thesimpsonator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
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'

Reply With Quote
  #7  
Old April 17th, 2008, 08:23 AM
Frank20 Frank20 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 246 Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 1 m 31 sec
Reputation Power: 9
Quote:
Originally Posted by thesimpsonator
getnewequipment.Fields.Item("GammiesPrice").Value getnewequipment.Fields.Item("price + vat?").Value
You can't just continue statements like this. You have two unrelated statements that do entirely different things on the same line.

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.

Reply With Quote
  #8  
Old April 17th, 2008, 09:38 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 734 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 9 h 19 m 57 sec
Reputation Power: 606
Send a message via Yahoo to zynder
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

Reply With Quote
  #9  
Old April 18th, 2008, 03:30 AM
thesimpsonator thesimpsonator is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 10 thesimpsonator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
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.........

Reply With Quote
  #10  
Old April 18th, 2008, 09:38 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 734 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 9 h 19 m 57 sec
Reputation Power: 606
Send a message via Yahoo to zynder
Try changing the code to

<% If getnewequipment.Fields.Item("GammiesPrice").Value <> "0" Then

Reply With Quote
  #11  
Old April 18th, 2008, 09:39 AM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 734 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1Folding Points: 110329 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 9 h 19 m 57 sec
Reputation Power: 606
Send a message via Yahoo to zynder
--removed--

Last edited by zynder : April 18th, 2008 at 09:41 AM. Reason: double posted

Reply With Quote
  #12  
Old April 18th, 2008, 11:20 AM
Frank20 Frank20 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 246 Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level)Frank20 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 9 h 1 m 31 sec
Reputation Power: 9
Do you see the...
Code:
%><%
...in the center of your line that you went and scrapped once you put this into an If Else? Those demarcated your VB code lines, distinguishing them from the HTML.

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.

Reply With Quote
  #13  
Old April 21st, 2008, 08:20 AM
thesimpsonator thesimpsonator is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 10 thesimpsonator User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 33 m 46 sec
Reputation Power: 0
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

Reply With Quote