Objectives of the Week
Let's start with an example
Download the Example .EXE to your Desktop (Zipped)
GUI - Graphical User Interface
To your user, the GUI is the application. The user interacts with the controls on the form to initiate events that your application will handle. Compare a GUI with a text-based interface that allows keyboard only input to procedural application. With a text-based interface tied to a procedural application, it is generally the program that controls the flow of events.
Event Driven Programming
The user controls how the program operates by initiating events such as Mouse Clicks and Keyboard KeyPresses. Your VB program must "Handle" these events. Each time an event occurs, that is every time the mouse is moved or a key pressed, a message is sent to Windows. It is Windows that determines which application is to receive that message and passes it on to the proper program. Visual Basic makes it easy to interpret the messages that are initiated by the user and passed on to the application by the Windows operating system.
An explanation of Windows Platform Programming from "Visual Basic Concepts" in VB Help
Object Model
A program in Visual Basic is built around the GUI. The GUI consists of a Form Object that is populated with Controls. Each Control has Properties (or characteristics that describe the control), Methods (or an action that is associated with the control), and Events (or user initiated actions that the application can be designed to handle).
VB Environment
When you open Visual Basic, this is what you will see:
Some of the sections of Visual Basic
Build the Example
Step by Step through the First Example
Click here to review some Programming Guidelines and the Save Project Procedure
Naming Conventions
When naming controls, give them a three character prefix that will reflect the type of control you are referencing:
Check Box | chk |
Command Button | cmd |
Form | frm |
Frame | fra |
Label | lbl |
Option Button | opt |
Text Box | txt |
Also note the structure of the Event Handler Procedure names:
A Command Button named cmdPush has a Click Event Procedure called cmdPush_Click
Different Types of Errors
Compile | A Syntax Error. You violated the VB coding rules |
Logic | An error where you get incorrect results |
Run Time | An error that caused your program to Terminate Abnormally |
Two Labs
Lab 1 - From the Text - Page 48, VB Mail Order
Step by Step through the First Lab
Let me know when you are done and I will check you off as Complete
Lab 2 - From the Text - Page 49, VB Auto Center
You are on your own.
Reading Assignment
Programming Assignment
The assignment is due before the start of class next week
Assignment Packaging Instructions
Build a program consisting of:
You must set your Form's Picture Property (Form.Picture) to an image that you will
download from this site.
The Label Control will be used to display a message based on the user clicking on the
first two command buttons. The third button will exit the program. You must set the Label
Caption to "The remote is there on the right!" in design mode. Clicking on the
first Command Button must change the Label Caption to "Well Done! You found
it!". Clicking on the second Command Button must change the Label Caption to
"Programmed by:" and your name. Clicking on the third Command Button will exit
the program..
Here is the user interface
Click Here to download the Background Image and the .EXE for the assignment
What you have to figure out on your own:
Follow the naming conventions! Be sure to test by using Run | Start with Full Compile Don't forget to code Option Explicit or your comment block at the beginning of the form.
Here is a list of the Program Grading Criteria
EMail me the Zipped Project Directory before the start of class next week.
As always, get started on this early, and if you have problems, email me with your specific question and a zipped copy of the project. Don't expect a quick response if you send your questions the day the assignment is due.