This article is also intended for asp tutorials. net is about asp.net tutorial c # and vb.net can only input English and digital functions, the first is c # limit can only input numbers and English, the last shows is vb.net, the principles are all one character, and then the internal code value is determined as follows.
C #
Private void textbox1_textchanged (object sender, eventargs e)
{
Char [] clist = textbox1.text. tochararray ();
String newstr = "";
For (int I = 0; I <clist. length; I ++)
{
Int ascii = (int) clist [I];
If (ascii> 127)
{
Clist [I] = '';
}
Newstr + = clist [I]. tostring ();
}
Textbox1.text = newstr;
}
Vb.net
Function valitext (keyin as integer, validatestring as string, editable as boolean) as integer
Dim validatelist as string
Dim keyout as integer
If editable = true then
Validatelist = ucase (validatestring) & chr (8)
Else
Validatelist = ucase (validatestring)
End if
If instr (1, validatelist, ucase (chr (keyin), 1)> 0 then
Keyout = keyin
Else
Keyout = 0
End if
Valitext = keyout
End function
Call method
Private sub txtmoney_keypress (keyascii as integer)
Keyascii = valitext (keyascii, "0123456789.", true)
End sub
Private sub txtid_keypress (keyascii as integer)
Keyascii = valitext (keyascii, "0123456789-abcdefghijklmnopqrstuvwxyz", true)
End sub