Discussion Locked

URGENT VB Format a number

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi

I am building an eCommerce site. The payment gateway does not accept decimal points in the amount. EG. $100.25 must be 10025. How can I format this? is it inbuilt or do I need to develop my own function. I am using VB.

Urgent assistance appreciated.

10 replies

by mark fenwick

The problem is that, this is not a formatting issue, 100.25 and 100025 are different numbers.

This is not uncommon for payment gateways, can you not multiply the amount by 100 and submit the request in cents?

This is usually the best way to overcome this.

Hope this helps.

Mark

by bob sellman

Define a variable as a long integer and use it as the value to pass to the gateway (and to receive values from the gateway if that also occurs).

Instead of using your currency value, when passing a value to the gateway, set the long integer variable = 100 * currency value.

If you are reading from the gateway, set the currency value = (integer variable [value passed by the gateway])/100.

Or multiple by .01 if you prefer.

Does the payment gateway pass everything as text? If so, then you'll have to also convert the integer to text to pass to the gateway (and the gateway value to integer before converting to currency). You could also do it as a more complex statement in one step for each way, rather than two.

By using the longinteger variable you insure that the number is a pure number (in effect, an even number of cents).

by toddseiber

I have use Bob Sellman's method in the past. The logic works perfectly.

Beware of using the Replace method since it will eval a currency value of 10.20 (10.2) as 102 and 10.00 (10) as 10. I made this mistake the first time I needed to handle WebAuthorize.

This discussion is closed to new replies.