Link to home
Start Free TrialLog in
Avatar of MIGS
MIGS

asked on

Automatic comma separator per thousand while entering numbers

hello guys,

a system user of mine asked if i could insert automatically a comma per thousand in her entry. i've done it automatically using the chage event and the format function. my problem is the decimal point and the numbers after it, since she is entering an amount.

could anyone help me with this please.....

 
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Try use the Replace function.

like:

text = Replace(text,vbcrlf, ";" & vbcrlf)
Avatar of DocM
DocM

Hi,

You could use the MaskedEditBox.
MaskEdBox1.Mask = "###,###.##"
For inputformatting use MaskedEditBox (like DocM said) or
on LostFocus event : Text1.Text=Format(Text1.Text, "Currency")

VB-Help:
 
Currency
   Display number with thousand separator, if appropriate;  
   display two digits to the right of the decimal separator.
  Output is based on system locale settings.
If the user is entering a number into a text field can you use this in your Change event?

'Remove any commas in the number
Text1.Text = Replace(Text1.Text,",","")

wrkNumber = Val(Text1.Text)

Text1.Text = Trim(Format(wrkNumber, "###,###,###,###,###.###########"))
ASKER CERTIFIED SOLUTION
Avatar of jayeshshah
jayeshshah
Flag of United States of America 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
Its all a case of whether you want to see the number being formatted as its typed in.
Hi MIGS,
This old question (QID 20569849) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept jayeshshah's comment as answer
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GrahamSkan
EE Cleanup Volunteer