test an input with currency ($) on vbscript

September 23, 2011 at 06:48:37
Specs: Windows 7 Home edition
hello again. I have a vbscript that will basically

- take an input from another program which is a currency ($)
- as it is being taken by vbscript, the input will be tested if it is (price) the same as the supplied input

Upon running, I'm getting different results
Here's a part of my code:

Dim price

price = iim1.iimGetLastExtract()

If price = "$4.95" Then
MsgBox "The data is equal"
Else
MsgBox "This is the price" & price
Quit

My questions are:
1. How can I correctly declare a currency data in vbscript?
2. How will I compare it correctly to $4.95?

Again, any responses from you will be very much appreciated.


See More: test an input with currency ($) on vbscript

Report •


#1
September 23, 2011 at 07:53:22
1. How can I correctly declare a currency data in vbscript?
You can't. VBScript uses variants, and only variants. You can force a currency type by passing a variable though CCur(), but that's about it.

2. How will I compare it correctly to $4.95?
Convert it to a number, and compare. Again, CCur() helps, but it'll throw a Type mismatch error if it doesn't like the string you feed it.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question