0% found this document useful (0 votes)
53 views

The Code Window: Computer II: Programming With VB6

This document provides an introduction to the code window in VB6 and programming with controls. It discusses accessing the code window, the parts of the code window like the object and event list boxes, and good programming practices like indenting code and using auto-complete when setting properties. It includes a hands-on example of writing code for click events on two command buttons to set the caption of a label.

Uploaded by

ephraim_q
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

The Code Window: Computer II: Programming With VB6

This document provides an introduction to the code window in VB6 and programming with controls. It discusses accessing the code window, the parts of the code window like the object and event list boxes, and good programming practices like indenting code and using auto-complete when setting properties. It includes a hands-on example of writing code for click events on two command buttons to set the caption of a label.

Uploaded by

ephraim_q
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

The Code Window

Computer II: Programming with


VB6
What have we learned so far?
• Saving Projects properly
• Placing Controls on the Form
• Changing the Name Property of a Control
• Setting other properties of a Control
What do you think are the names of
these controls?
Form at Run Time
What makes a program work?
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 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

Private Sub cmdYes_Click ()

lblText.Caption = “Welcome!!!”

End Sub
Good Programming Practices
To improve the readability of your code:
• Indent the lines between the Private Sub and
End Sub
• Places spaces between lines
Good Programming Practices
To be more accurate in creating subprocedures
• Double-click the control (this automatically
types the Private Sub and End Sub)
• When typing the Property, choose from the list
box that comes out after typing the first letters
then press Space
Hands On 3: Entry
Place the following in the Code
Window then modify the settings as
you see fit
Private Sub cmdNo_Click()
lblText.Caption = "Goodbye! See you soon!"
End Sub

Private Sub cmdYes_Click()


lblText.Caption = "Welcome!!!"
End Sub

You might also like