Chuckbuchan
asked on
converting numbers(currency) to strings in VB
I would like to know about a predifined function, or a sort of algorithm, that converts the numbers (Currency) to strings.
example when I calculate an amout of a bill if it rings $200.57 , it should say Two Hundred Dollars and Fifty Seven Cents.
Thanks you,
example when I calculate an amout of a bill if it rings $200.57 , it should say Two Hundred Dollars and Fifty Seven Cents.
Thanks you,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There are lots of questions about this here in EE:
https://www.experts-exchange.com/questions/20071926/Converting-a-number-into-text.html
https://www.experts-exchange.com/questions/20247475/converting-1250-into-one-thousand-two-hundred-fifty-in-vb.html
https://www.experts-exchange.com/questions/10045775/Converting-numbers-to-actual-words.html
One of most mentioned is this:
http://www.mvps.org/access/modules/mdl0001.htm
https://www.experts-exchange.com/questions/20071926/Converting-a-number-into-text.html
https://www.experts-exchange.com/questions/20247475/converting-1250-into-one-thousand-two-hundred-fifty-in-vb.html
https://www.experts-exchange.com/questions/10045775/Converting-numbers-to-actual-words.html
One of most mentioned is this:
http://www.mvps.org/access/modules/mdl0001.htm
The answers above might be good.I think those are not sophisticated at all...let me tell you my idea.
The easiest way is to read the number from left, every 3 main digits (e.g. 123 million 456 thousand 456) till you reach the decimal. Then you print " Dollars " and read the 2 numbers after the decimal...
To be well organized, I'd used 4 or 5 methods. One of them receives a single digit to read, method2 receives 2 digits to read and obviously they return a string. You would call the methods recursively.
So you put this in method 1 with a 'select case' which is easier than 'if' statements.
"One"
"Two"
"Three"
"Four"
"Five"
"Six"
"Seven"
"Eight"
"Nine"
and this in method 2:
select case
"Ten"
"Eleven"
"Twelve"
"Thirteen"
"Fourteen"
"Fifteen"
"Sixteen"
"Seventeen"
"Eighteen"
"Nineteen"
The easiest way is to read the number from left, every 3 main digits (e.g. 123 million 456 thousand 456) till you reach the decimal. Then you print " Dollars " and read the 2 numbers after the decimal...
To be well organized, I'd used 4 or 5 methods. One of them receives a single digit to read, method2 receives 2 digits to read and obviously they return a string. You would call the methods recursively.
So you put this in method 1 with a 'select case' which is easier than 'if' statements.
"One"
"Two"
"Three"
"Four"
"Five"
"Six"
"Seven"
"Eight"
"Nine"
and this in method 2:
select case
"Ten"
"Eleven"
"Twelve"
"Thirteen"
"Fourteen"
"Fifteen"
"Sixteen"
"Seventeen"
"Eighteen"
"Nineteen"
See this link: http://www.vb-helper.com/howto_number_to_words.html
bkt