Using Commas reversing the order

I have a string of numbers that I want to denote by 1000's.  Ex. 123456789 would be 123,456,789....I have tried to use

text1.text = format(text1.text,"###,###,###") and I have also tried to use the formatnumber method but the string that gets returned ends up wit the numbers in some type of "wrapped" order..Ex. instead of 123,456,789....I get   895,671,234.......Please Advise
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I tried these, and they all work for me:

CStr(Format(CDbl(Text1.Text), "#,##0.00"))

CStr(Format(CDbl(Text1.Text), "#,###"))

Format(Text1.Text, "#,###")

If you're code looks the same as mine, it could be because:
- someone has entered a value that's not correct (I don't know where your from, but in Holland we are quite used to use a '.' to denote 1000's and a ',' for a decimal 'point'. Even though I programmatically tell to use a comma, if the international settings are Dutch, it will show a '.' This way you'll get conversion errors.

Anyway it is a good idea to evaluate whether the string is numeric or not by throwing in the IsNumeric() function. If your string is not a valid number, it will return false. (Though it will return true also for strings like "12.9,09.98"

I've never experienced scrambled strings as a result of a format.
"Though it will return true also for strings like "12.9,09.98""

I didn't believe you, but it's true. O dear. (In English locale, it will return True for 12,9.09,98)
johnmhatAuthor Commented:
Thanks but I have tried that code, and it does supply the commas but it still returns the numbers in a different order.

The order entered is 123456789 but the order that is displayed is


where 1234 are entered and then the comma is placed after the 1 then once the comma is placed the cursor is set to the beginning of the string and  once the 5 is enterd the number appears as
51,234 and so on until the number above is the final result...Ideally I would like the number to appear as
123,456,789 as entered....
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Okay, so it seems you're using the format command during the Change event. In that case you should try and add the following line to your code:


If I'm wrong about where you put you're code, please tell me exactly what you do and when

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
johnmhatAuthor Commented:
Thank you very much!  I am still new at this, what does that line of code do exactly....
Well, that line of code tells the cursor where to be. Say you've got a textbox called Text1 and in it is a line of text like 'hello'.

Some scenario's
text1.Selstart=0 -> the cursor is blinking at the beginning of the textbox, before the text

Text1.SelStart 3 -> the cursor is blinking after the third character

The line of code I gave you tries to figure out the length of the string in the textbox, and places the cursor at the end of the text.

Another property that you might like is the SelLength property. A statement like


would select the entire text in your textbox.

Have fun...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.