# 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
``````
However, if Canadian currency is sent gives a run-time 13 type mismatch error.

``````Print ccur("C\$16,000.1")
``````

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.

###### Who is Participating?

RetiredCommented:
This function should chop of non-numeric leading characters
``````Function MyCCur(vNumber As Variant) As Currency
Do Until IsNumeric(Left(vNumber, 1))
vNumber = Mid(vNumber, 2)
If Len(vNumber) = 0 Then
vNumber = 0
End If
Loop
MyCCur = CCur(vNumber)
End Functio
``````
n
0

RetiredCommented:
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\$.
0

Author Commented:
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
``````
0

Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.