Results 1 to 2 of 2

Thread: [RESOLVED] Textbox and string record

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] Textbox and string record

    I don't want allow user to insert the string value in the textbox. How I can do that?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Textbox and string record

    vb Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2. If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 46 And KeyAscii <> 13 Then
    3.     MsgBox "Only numbers are allowed for this entries"
    4.     KeyAscii = 0
    5.     Exit Sub
    6. End If
    7. End Sub
    8.  
    9. 'also, in the change event put this code
    10. 'to prevent pasting in non numeric text
    11. Private Sub Text1_Change()
    12. If Not IsNumeric(Text1.Text) Then
    13.    MsgBox "Only Numbers Are Allowed"
    14.    Text1.Text = vbNullString
    15.    Exit Sub
    16. End If
    17. End Sub

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