vb.net - Error Handling in vb 2015 click event -


i learning vb 2015. have developed windows application give lookup capability access database id, name, company , phone #. user selects type of lookup via radio button. bring second form asks user input in textbox , displays datagridview of matching rows. when user presses button accept input click event extensive validation of input , shows message box if input invalid. @ point want clear textbox , give focus user can reenter id, phone #, etc. have googled , tried number if options no joy. if set .clear , .focus in click event , return focus not in textbox. user can click text box , enter new request seems more elegant put focus in textbox.

where control return after click event? there standard way of handling in vb.net?

it possible throwing exception during validation code.

try putting risky operations in try...catch block, , necessary operations in area. make sure clearing, , re-focusing last thing do.

private sub button1_click(sender object, e eventargs) handles button1.click     try         ' validation code     catch ex exception         ' handle exception             textbox1.clear()         textbox1.focus()     end try end sub 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -