|
-
Jan 2nd, 2002, 12:56 PM
#1
Thread Starter
Frenzied Member
format number after lost focus
Ok all,
Hopefully this is an easy one...
I have users entering numbers in text boxes... and some of them are rather lengthy... and I want to format the numbers with commas and return the number to the same text box when the user moves on to another box.
For example:
Take 123456789 and convert it to: 123,456,789
Any quick fixes for this?
-
Jan 2nd, 2002, 01:17 PM
#2
Junior Member
Create yourself a form with two text boxes, text1, and text2 on it. Then paste this code into your form....
Code:
Private Sub Text1_LostFocus()
If IsNumeric(Text1.Text) Then
Text1.Text = Format(Text1.Text, "###,###,###")
Else
MsgBox "Please enter a valid number"
End If
End Sub
Note that when you press TAB to move to the second text box, or click somewhere else, the value you entered will be correctly formatted.
Hope this helps
Regards,
Mark Wills
UK
-
Jan 2nd, 2002, 01:30 PM
#3
Thread Starter
Frenzied Member
Excellent!!
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|