View contents of this chapter

Writing Code

Adding VB programming statements will turn your application into a working application. The Code Editor window is used to write Visual Basic code for your application. Code consists of language statements, constants, and declarations.

Play Sound Using the Code Editor window, you can quickly view and edit any of the code in your application.

To open the Code window

  • Double-click the form or the control for which you want to write code or
  • From the Project Explorer window, select the name of a form or module, and choose the View Code button.

Now, double click the Command Button. The Form disappears and the Code Window appears with the following lines at the top:

Private Sub Command1_Click()

End Sub

Code in a Visual Basic application is divided into smaller blocks called procedures. All code appears in procedures, and all procedures require beginning and ending lines.

Play Sound VB automatically adds the first and final line of many procedures.

Play Sound A procedure contains code that performs a specific task.

The Code window includes the following elements:

  • Object list box — It displays the name of the selected object. You can view a list of all objects associated with the form by clicking the arrow to the right of the list box.
  • Procedure list box — It lists the procedures, or events, for the selected object.

 



© Universal Teacher Publications        INDEX Previous Screen Next Screen