Visual Basic Programming - Concepts
This class is meant to offer information on the programming language Microsoft Visual Basic 6 (VB6). It is highly suggested that students own a copy of VB, that way they can create a hands-on experience for themselves. If you do not have a copy, you may still learn how to write code in VB. Creating the form and setting properties will only be lightly touched, and the class will mainly focus on code. To go to the next page, follow this link: Visual Basic Code
. To go back to the Academy, please click here: Elftown Academy
2. [One Ruler
3. [A Beautiful Oblivion
1. Declare Everything!
3. Changing Properties with Code
5. If... Then... (Else...) Statements
I cannot stress this enough. Declare every variable you have, or you will have a much harder time programming. Here's the basic structure for declaration:
All you have to do is change Variable
into something meaningful and Type
into a proper type. Types are things such as: Integer, Long, Single, Double, String, Byte, etc. An example of declarations is:
Dim intCounter as Integer
Dim strNames as String
Dim DoctorList(20) as String
Dim Billy as Byte
Alright, interface is basically summed up as the form and everything on it. Since most people won't have a copy of it, this is about all most people will get. When you create the interface, try to make sure that everything looks similar, especially if you are using multiple forms.
Changing Properties with Code
Properties are information about controls. Each one changes the control it applies to in some way. To change properties with code, the statement is as follows:
= New Setting
Examples of this is use are:
Image1.Top = 230
txtName.Text = "VB Rocks"
lblDisplay.Caption = "Hello World"
Variables are data containers. The normally have a meaningful name, but can also be random combinations of letters and numbers. Types of variables include: Long, Single, Double, String, Byte, Variant, Date, etc. Here are summaries of the most frequently used types:
- Integer: Integer value, can be positive or negative.
- String: Any assortment of words, letters, or numbers.
- Currency: Decimal values or integers, in regular number form.
-Variant: Changing type, can hold anything.
If... Then... (Else...) Statements
If... Then... (Else...) Statements are probably one of the most used elements in coding. These follow one of these simple structures:
Basically these mean: If this is true then do this, else do this.
Back to Computer Science or the Elftown Academy