Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    TextBox Validation (XP)

    Hi all,
    Is it possible to limit textbox values to text only and if so, how?
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Validation (XP)

    hi Rob,

    sure. insert a keypress event for the textbox you want to validate:

    Private Sub TextBox1_KeyPress _
    (ByVal KeyAscii As MSForms.ReturnInteger)
    Debug.Print KeyAscii
    Select Case KeyAscii
    Case 65 To 90, 97 To 122
    Case Else
    KeyAscii = 0
    End Select
    End Sub

    the above event will only allow a-z, A-Z keys. i inserted a debug.print keyascii which sends every keycode to the immediate window also, so if you would like to allow an exlamation mark to be typed also, simply go to your textbox and press an exclamation mark, go back to the immediate window to view the code for this key and add it to the case structure. after you've added all the keys you want to allow, comment out or delete the debug.print codeline.

    greetings,

  3. #3
    4 Star Lounger
    Join Date
    Sep 2002
    Location
    Stafford, Staffordshire, England
    Posts
    585
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: TextBox Validation (XP)

    Hi Pieter,
    Thanks for the information. It has been very useful.
    <font color=blue><font face="Script MT Bold"><big>Rob</big></font face=script></font color=blue>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •