Results 1 to 3 of 3

Thread: format number after lost focus

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    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?

  2. #2
    Junior Member
    Join Date
    Jan 2002
    Location
    Shrewsbury, Shropshire, UK.
    Posts
    30
    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
    Ouch. My head hurts.

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    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
  •  



Click Here to Expand Forum to Full Width