Introduction to Visual Basic 6
Steps To Creating a Program:
1. Program Specifications: Decide what the program must do.
2. Screen design: Outline what the screen will look like on paper.
3. Painting the program: Make the screen look right. Create all the objects and rename them using the standard prefixes and set their properties.
4. Coding: Write the commands for the objects to perform correctly.
5. Testing (test all possibilities) and debugging (correcting the errors): Evaluation (probably done by another person and the teacher).
Visual Basic 6.0 B Class Notes
Visual Basic Programming Environment
Controls/Objects In VB, all the controls you place on a form and the form itself are called objects.
Examples of objects:
form - a windows screen
command button
label - user can not change during run time
text - user can change during run time
horizontal scroll bar
picture
shape
The Toolbox contains the following standard controls:
PictureBox Label TextBox
Frame CommandButton CheckBox
OptionButton ComboBox ListBox
HScrollBar VScrollBar Timer
DriveListBox DirListBox FileListBox
Shape Line Image
When placing several controls on a form, use the commands on the Format menu to place and size the controls. First, drag the mouse around the controls to select them. Using the commands on the Format menu, you can then align or size the controls as necessary. Control properties can generally be set at either design time or run time
Here is a form with Label, TextBox and CommandButton controls
Label Control
A label is a graphical control used to display text. Because a label is a graphical control, the user cannot edit the text directly. The most common use for a Label control is to identify controls that do not have a Caption property, such as the TextBox control. You can also use the Label control to display text such as status messages and other program information.
For more information about label properties, methods, and events, see ALabel Control@ in Visual Basic Help and click on properties.
TextBox Control
You use a TextBox control to obtain information from the user or to display information provided by the application. Unlike information displayed in a label, the user can change information displayed in a text box. Text boxes can be used in conjunction with a Data control to display information from a database. You can also use text boxes to set up database queries or to edit records in a database.
For more information about the properties, methods, and events of the TextBox control, see "TextBox Control" in Visual Basic Help.
CommandButton Control:
A command button performs a task when the user clicks the button. You use a CommandButton control to begin, interrupt, or end a process. When clicked, a command button appears to be pushed in and so is sometimes called a push button. The most common event for a CommandButton control is the Click event.
Code:
Every VB object has code (programs) attached to it. When the user clicks on the object, VB will execute this program. Double click on an object in the object window to bring up its code window which looks like:
Private Sub objectname_Click()
End Sub
Your commands go in between Private Sub and End Sub.
Warning: Never erase or change Private Sub and End Sub.
Warning: Always rename your objects before coding them or the code will not be executed for the correct objects.
Commands - commands are the lines of code you type in order to get the program to perform as you desire.