VB.Net get text after keypress -



VB.Net get text after keypress -

i running custom validations on textbox keypress event.

when user presses key want find out text exist after particular key press.

eg. if textbox contains 12.4 , user press "6" key want find out text afterwards. tried appending e.keychar end of textbox.text there problems if user highlights portions of textbox , press key.

is there anyway observe actual value exist after key has been pressed?

you have disassemble current text based on current caret position, examine incoming text, , reassemble text again:

private sub textbox1_keypress(sender object, e keypresseventargs) _ handles textbox1.keypress dim part1 string = textbox1.text.substring(0, textbox1.selectionstart) dim part2 string = textbox1.text.substring(textbox1.selectionstart + _ textbox1.selectionlength) dim character string = string.empty if char.isdigit(e.keychar) character = e.keychar.tostring dim result string = part1 & character & part2 'do result... else e.handled = true end if end sub

vb.net

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -