• TextBox Validation (XP)

    Author
    Topic
    #383847

    Hi all,
    Is it possible to limit textbox values to text only and if so, how?

    Viewing 0 reply threads
    Author
    Replies
    • #656046

      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,

      • #656091

        Hi Pieter,
        Thanks for the information. It has been very useful.

    Viewing 0 reply threads
    Reply To: TextBox Validation (XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: