Hi all, I know this is proberbly a really basic question but how do you reload a form, I'm need to put some code in a catch - end try block that will reload the form or allow the user to re enter a value in textbox2.
Hi all, I know this is proberbly a really basic question but how do you reload a form, I'm need to put some code in a catch - end try block that will reload the form or allow the user to re enter a value in textbox2.
How do you reload a form
sabman
Just handle the KeyChar event for your textbox and add this code to the event handler:
e.Handled = Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar) )
This sets the handled flag to true if the key is not a number or a control character ( such as an arrow ), and setting it to true causes the stroke to be ignored.
happy_84k
I think only allowing the textbox to accept certain types of input would be best, I need it to accept numeric only input, how would I do that. Thanks for your help.
Joost Ploegmakers
The best way to do validation is to handle the leave event of the text box, and tell the user right away that they need to make a correction. You can also make changes to a textbox so it only accepts certain input, or use a maskedtextbox, if you're in VS2005.
How do you mean reload Do you mean to restore it to it's initial state, or is your code throwing an exception If your text box input can cause an exception, your code should anticipate this, not catch it.
Andla
Thanks for your help but could you explain exactly what I need to do. I'm a bit of a newbie with V.B .
First can I just confirm this is the event handler :
Private
Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChangedEnd
SubWhen I paste the code you quoted into the event handler I get errors on : e.Handled & e.keychar
Handled ( or KeyChar) is not a member of system.eventArgs