Sunday, April 1, 2012

Allow only numeric or Characters to Textbox

This event procedure will be executed before key value is applied to text box in .net.This event procedure allowed developer to kill the functionality of key.Here i have two text boxes one for allow only numeric and second one is allow only characters
//keypress event
msgbox("keypresslogic")
msgbox(e.Keychar&" "&Asc(e.Keychar)
If Asc(e,Keychar)=8 Then
Exit sub
EndIf
//To allow numeric
If(char.IsDigit(e.Keychar)=Flase Then
e.Handled=True
MsgBox("enter numeric)
EndIf
EndSub

No comments: