Flying Lemurs: Fly for Fun

TUTORIALS


Basic Visual Basic Project
The easiest Visual Basic project to create a useful window.

Open Visual Basic and start a new project, selecting "Standard EXE"
At this point a simple window is created. A grid shows where controls may be placed.

Place a command button on the form by selecting the command button from the toolbar and then clicking and dragging on the form to determine the button size. Run the project to test the control. Your button will depress, but it won't do anything yet.

Next, stop the program by clicking on the "X" and then double-click on the command button you placed on the form and the code window will open. The simplest code will create a message box.

Place this code between the "sub" tags in the code window: iReturn = MsgBox("Continue?", vbOKCancel, "Continue")

The iReturn is a general variable capable of accepting the returned value from the message box function. This value will contain the user's response to the message box: which button they pushed, "OK" or "Cancel". Your program will be able to decide what to do based on this value.

iReturn = MsgBox("Continue?", vbOKCancel, "Continue")
If iReturn = 2 Then
iResponse = MsgBox("Return Value is " + Str(iReturn), vbOKOnly, "They clicked Cancel")
End If
If iReturn = 1 Then
iResponse = MsgBox("Return Value is " + Str(iReturn), vbOKOnly, "They clicked OK")
End If

This creates your basic program which allows the first capabilities with communicating with a user.



Copyright 2008 Flying Lemurs.