vb.net - VB 2012 TextBox.Clear() not working -
i'm working on encryption program , uses "pin" calculate stuff encryption. have textbox user can insert "pin". i'd prevent people entering numbers. added on keypress event:
if not char.iscontrol(e.keychar) if not char.isnumber(e.keychar) msgbox("invalid character", , "warning!") textbox3.clear() end if end if
it shows msgbox , doesn't write textbox until close th emsgbox. typed character appears in textbox. when write 1 works same before, replaces last character instead of writing one. there i'm missing because looks bug me?
set es_number windows style textbox:
public class form1 public const gwl_style integer = (-16) public const es_number integer = &h2000 public declare function getwindowlong lib "user32" alias "getwindowlonga" _ (byval handle intptr, byval nindex integer) integer public declare function setwindowlong lib "user32" alias "setwindowlonga" _ (byval handle intptr, byval nindex integer, byval dwnewlong integer) integer public sub setnumbersonlytextbox(byval tb textbox) setwindowlong(tb.handle, gwl_style, getwindowlong(tb.handle, gwl_style) or es_number) end sub private sub form1_load(sender system.object, e system.eventargs) handles mybase.load setnumbersonlytextbox(textbox3) end sub end class
Comments
Post a Comment