Link to home
Start Free TrialLog in
Avatar of jana
janaFlag for United States of America

asked on

convert a string containing currency data into a currency or decimal in vb6, no matter the country currency

We have a code when called, the currency amount is passed to.  If the currency is US Dollar, it's ok.

Example

Print ccur("$16,000.1")
 16000.1 

Open in new window

However, if Canadian currency is sent gives a run-time 13 type mismatch error.

Print ccur("C$16,000.1")

Open in new window


We know it has to do with the regional setup of the computer (we think).

We tried:
val("C$16,000.1")
results is 0

Also CDbl, CDec, CLng, CULng, etc.

Please advice on the correct method to go about it.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

CCur is intended to work on numbers, converting any numerical input to the Currrency subtype.

With string input it ignores the regional leading currency symbol. On my system with UK setting the $ sign gives an error, but £ sign does not.

Via the regional settings it is possible to set any single character to be the currency symbol, but not two as in C$.
Avatar of jana

ASKER

Thanx for the info, prior placing the question we tried various setup via Regional but no success.

Is there another way to convert a the following value when the currency is not of USA?

Example, we would like while in the USA, convert a string Canadian currency to decimal value:
"C$16,000.10"  to 16000.1

Open in new window

1. C$16,000.1 is not a standard format for international currency.
2. How many different currencies are in need of conversion?
3. Please post examples of those currency string values and the numeric value you need.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial