Site hosted by Angelfire.com: Build your free website today!

EXTRA INFO

Getting Started with VB6

GUI

Removing the form

Getting to the Next Lesson

Code Used

 

Tutorial 1
Code Used

AIM - To understand and learn all code before tutorial 2

 

To be able to understand how to program you need to learn the code below BEFORE you move on to Tutorial 2. Once you understand the code - cut and paste the table into a Word document and keep it for your future reference. VB6 is NOT case sensitive but it is a good idea to get into the habit of using the same spellings and for your variables.

Code Meaning
Sub Main() This code starts the program
End Sub Ends the program
msgbox

Creates a message box
Example:
msgbox ("Hello World")
Creates a message box that says Hello World.

InputBox

Creates an input box, must have a variable to store input
Example:
Name=InputBox("Please enter your name below")
Creates an input box that asks for the user name

If..Then..End If

Allows the program to set a condition or compare something and then do something (one option choice)

Example
If Name = "Dave" Then

Msgbox "Hello Dave"

End If

If..Then..Else..End If

Allows the program to set a condition or compare something and then do something or something else (two option choices)

Example
If Name = "Dave" Then

Msgbox "Hello Dave"

Else

msgBox "Who are you?"

End If

If..Then..ElseIf..Else..End If

Allows the program to set a condition or compare something and then do something, or something else, or something else (three option choices)

Example
If Name = "Dave" Then

Msgbox "Hello Dave"

ElseIf Name= "Lynda" Then

msgBox "Hello Lynda "

Else

MsgBox "I don't know you"

End If

The options can be further extended by repeating the ElseIf staement. Later in Level 2 we will use a case statement for many choices.

IsNumeric

Returns the value True if a variable contains a number.
Example
If IsNumeric(Number1) = True then

UCase

Converts to UPPER case
Example

Name= UCase(Name)

Converts whatever is stored in Name to capital letters. If name held Dave it would now be DAVE

LCase

Converts to lower case
Example

LCase(Name)

Converts whatever is stored in Name to small letters. If name held Dave it would now be dave

Val Converts a string to a numeric value
Str$ Converts numbers to strings
Dim Short for Dimension, gets some space to store a variable.
Dim Name as String Full variable declaration to create some space and store a text value.
InputBox (advanced) Creates an inputbox with a title and dfault text value
Name=Inputbox("Enter Name", "Title", "Default Text")
MsgBox (avanced) Choice=msgbox("Enter Name",typeOfMsgbox+Icon, "Title")
' REMs comments are NOT treated as code. ' needed for every new line of text.
Option Explicit All variables MUST be declared