Displaying control-specific instructions in VB6 with GotFocus
Takeaway: The GotFocus event for a control fires in VB6 when the control receives the focus through user action or through the SetFocus method. See how you can use GotFocus to display information or instructions to the user.
The GotFocus event for a control fires in VB6 when the control receives the focus through user action or through the SetFocus method being executed in the code. You can use GotFocus to display information or instructions to the user, perhaps in a Status Bar control.
For example, suppose there is a TextBox where the user is supposed to enter a phone number in a specific format. You could inform the user of the format as follows:
Private Sub txtPhoneNumber_GotFocus()
Status1.Text = "Please enter the phone number in this format: xxx-xxx-xxxx"
End Sub
You can also use a control's LostFocus event to clear the message when the focus moves away from the control to prevent possible confusion.
Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Miss a column?
Check out the Visual Basic Archive, and catch up on the most recent editions of Peter Aitken's article.
Print/View all Posts Comments on this article
SponsoredWhite Papers, Webcasts, and Downloads
- 2008 IT Salary and Skills Report Global Knowledge
- Eleven Myths about 802.11 Wi-Fi Networks Global Knowledge
- Preparing for and Taking the PMP Certification Exam Global Knowledge
- Vista SP1: What You Need To Know Before You Deploy Global Knowledge
- ITIL Version 3.0 -- What It Means to You Global Knowledge
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET
