The Code Window: Computer II: Programming With VB6
The Code Window: Computer II: Programming With VB6
The Code Window: Computer II: Programming With VB6
lblPrompt
lblText
cmdYes cmdNo
Form at Run Time
Code Window
Accessing the Code Window
• Clicking on the View Code button on the
Project Explorer Window
• Selecting a Control and Pressing F7
• Double-Clicking on a Control
Parts of the Code Window
Object List Event List
Box Box
Code Area
Object List Box
• Lists the objects or controls in the form
Event List Box
• Lists all events or procedures related to the
selected control
Terms to Remember
• Controls – also called objects
• Procedure – events; declarations that are
performed when you do an action to an object
• Private – indicates that the procedure will only
take place inside the form
• Sub – stands for subprocedure
• Private Sub – start of a subprocedure
• End Sub – end of a sub procedure
Sample Code
Translation: Do Name of
the following if Control Event
Private Sub cmdYes_Click ()
cmdYes is
Clicked
lblText.Caption =
“Welcome!!!”
Name of Property Setting
Control
Translation: Change the
caption property of lblText
to Welcome!!!
End Sub
Good Programming Practices
To improve the readability of your code:
lblPrompt
lblText
cmdYes cmdNo
Place the following in the Code Window
then modify the settings as you see fit