Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Text only in a textbox

Text only in a textbox

Scheduled Pinned Locked Moved Visual Basic
csharpjavahelptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ADY007
    wrote on last edited by
    #1

    how to make a textbox that the user can enter only text no numbers! help me please! :( Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.

    S R M 3 Replies Last reply
    0
    • A ADY007

      how to make a textbox that the user can enter only text no numbers! help me please! :( Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.

      S Offline
      S Offline
      space_doggy
      wrote on last edited by
      #2

      Hope this helps: set the e.Handled flag to true in the KeyPress event if the value is in the range that you wnat to ignore. Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_user_name.KeyPress Select Case e.KeyChar Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" e.Handled = True End Select End Sub

      1 Reply Last reply
      0
      • A ADY007

        how to make a textbox that the user can enter only text no numbers! help me please! :( Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.

        R Offline
        R Offline
        Robo16
        wrote on last edited by
        #3

        Hiya I was surfing the web looking for an answer to the same problem and found an extremely low priced suite of controls called ITTeamControls .Net. It includes TextBox that has an AllowedKeys property. You can set it to allow text only, numbers only or all. So there is no code involved. The web page is http://www.itteam.net/itteamcontrols.html[^] They have a number of low priced utilities for .Net developers. We have bought stuff off them. Hope this helps Rob -- modified at 5:59 Friday 26th May, 2006

        1 Reply Last reply
        0
        • A ADY007

          how to make a textbox that the user can enter only text no numbers! help me please! :( Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.

          M Offline
          M Offline
          Mohammed Amine
          wrote on last edited by
          #4

          Hi , it is just pretty simple i had this problem before but i solved it with this just copy & past & it will work if you don't understand the code i can explain it for you too :) Public Function FiltreStringASCII(ByVal var As Integer) As Boolean If var = 8 Or var = 32 Or var > 64 AndAlso var < 91 Then Return True ElseIf var > 96 AndAlso var < 123 Then Return True Else Return False End If End Function Public Sub Check(ByVal b As Boolean, ByVal e As System.Windows.Forms.KeyPressEventArgs) If b = True Then e.Handled = False Else e.Handled = True End If End Sub and now call this methods in the keypress event of the text you want to write just text in : Private Sub Textbox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Matr_Rec.KeyPress Check(FiltreStringASCII(Asc(e.KeyChar)), e) End Sub you can change the visibility of the methods over i just used Public cuz i call those methodes from an other class :) try to be good if you can't be the best -- modified at 8:07 Friday 26th May, 2006

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups