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"
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.