Click here to Skip to main content
14,693,856 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is the code in vb for enabling focus on certain objects like textboes, datetimepickers, or combo boxes until certain condition are met. Let's say,

Textbox A has the number "11", but the condition was if >= 10, then a messagebox will prompt user, followed by the user are unable to select other textboxes or buttons until the condition is met.

Is this possible in Visual BASIC? If so, how do we enable this function.
Posted

1 solution

Is this VB.NET, or VB6 ? In VB.NET the control has a Focus() method. Call that to put the focus back and check in the focus lost event, that way, the focus will go back there until they enter an OK value. Which is bad UI, really, your textbox should ideally only accept values in the correct range, and if the user can only enter 1-10, for example, a drop box is better UI.
   
Comments
Rickysay 19-Jul-12 22:47pm
   
I'm using Windows Form Application on Visual Studio 2008. Doesn't that mean i'm on Visual BASIC not VB.net or vb6? i'm uncertain as well.
Christian Graus 19-Jul-12 22:52pm
   
You're using VB.NET.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900