Results 1 to 3 of 3

Thread: textbox format

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Pilipinas
    Posts
    441

    textbox format

    I use this code to format the text of a textbox into a Currency Format:

    Private Sub Text1_Change()
    If Not IsNumeric(Text1) Then
    SendKeys vbBack
    End If
    '
    Text1 = Format(Text1, "#.#0")
    End Sub

    But there is something wrong with this;
    check this code first and advice me what code should i write?
    thanks

  2. #2
    Addicted Member akki's Avatar
    Join Date
    Jun 2003
    Location
    Jungle
    Posts
    220
    How about this one

    VB Code:
    1. Private Sub Text1_Change()
    2.     If Not IsNumeric(Text1.Text) Then
    3.         SendKeys vbBack
    4.     End If
    5. End Sub
    6.  
    7.  
    8. Private Sub Text1_Validate(Cancel As Boolean)
    9.     Text1.Text = Format(Text1, "#.#0")
    10. End Sub
    akki

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If Not (KeyAscii = vbKeyBack Or KeyAscii = Asc(".") _
    3.     Or KeyAscii = Asc(",") Or (KeyAscii >= Asc("0") _
    4.     And KeyAscii <= Asc("9"))) Then KeyAscii = 0
    5. End Sub

    applicable currency keys only

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