Saturday, 15 May 2010

vb.net - Is there a way to keep a Textbox triggered on Enter from accepting only spacebars -



vb.net - Is there a way to keep a Textbox triggered on Enter from accepting only spacebars -

i'm writing programme selects random colors, , pretty much every aspect of working point.

how works: can utilize either homecoming key, or button add together text textbox listbox.

how i'd act: doesn't take no entry, if textbox1.text = "" doesn't insert listbox, if user types "space""space""space" take blank text. i'd avoid there no blank entries in listbox.

relevant code:

private sub textbox1_textchanged(sender object, e system.windows.forms.keyeventargs) handles textbox1.keyup seek if e.keycode = keys.enter if textbox1.text = "" else lstcolors.items.add(textbox1.text) textbox1.text = "" end if end if grab end seek end sub

you remove spaces (using trim) before comparing blank:

if textbox1.text.trim() = ""

vb.net

No comments:

Post a Comment