ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
LostFocus Event Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example changes the color of a text box when it receives or loses the
' focus and displays the appropriate text in the label. To try this example,
' create a form with two text boxes and a label.
 
' In this example, the color of a text box changes when it receives (GotFocus
' event) or loses (LostFocus event) the focus. In addition, each time the
' scroll bar is clicked, the numeric setting of the scroll bar's Value
' property is displayed in a text box.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Choose New Form from the File menu to create a form with:
'    • Text box
'    • Label
'    • Horizontal scroll bar
' 3. Press Alt+F4 to return to the programming environment
' 4. Copy the code example below to the form module
' 5. Press F5 to run the example
 
 SUB Text1_GotFocus ()
     ' Show focus in red.
     Text1.BackColor = 4
     Label1.Caption = "Text1 has the focus."
 END SUB
 
 SUB Text1_LostFocus ()
     ' Show non-focus in green.
     Text1.BackColor = 2
     Label1.Caption = "Text1 does not have the focus."
 END SUB