Text only in a textbox
-
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.
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
-
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.
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
-
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.
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