Results 1 to 2 of 2

Thread: Help!

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2003
    Posts
    1

    Talking Help!

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If (KeyAscii = 65 to 90) Then '48 Or KeyAscii > 57) Then
    SendKeys "+({HOME})"
    MsgBox "Characters Only."
    End If
    End Sub
    --------------------------------------------------------------------------------
    Is this right? I only want letters to be typed in my textbox. if the user typed numbers there will be an error. this code doesn't seem to work. pls help.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.  
    3.     If Not (LCase$(Chr$(KeyAscii)) Like "[a-z]") And KeyAscii <> vbKeyBack Then
    4.         KeyAscii = 0
    5.     End If
    6.  
    7. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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