CIS 115 Lecture02 VB-Introduction
CIS 115 Lecture02 VB-Introduction
Integrated Common
Visual Basic
Development Language
compiler
Environment Runtime
1 2 3
Solution Assembly
Project
Intermediate Language (IL)
Source files
Class references
User creates a new project in Visual Studio
A solution and a folder are created at the same time with the same name as
the project
The project belongs to the solution
Multiple projects can be included in a solution
Solution
Contains several folders that define an application’s structure
Solution files have a file suffix of .sln
Project: contains files for a part of the solution
Project file is used to create an executable application
A project file has a suffix of .vbproj
Every project has a type (Console, Windows, etc.)
Every project has an entry point: A Sub procedure named Main or a Form
Solution folder
Solution file (.sln)
Project folder
▪ Project file (.vbproj)
▪ Visual Basic source files (.vb)
▪ My Project folder: contains configuration information
common to all projects
▪ The file AssemblyInfo.vb contains assembly metadata
▪ The References folder contains references to other assemblies
▪ The bin folder contains the executable file produced as a
result of compiling the application
Select the “Create Project” option from the “Recent
Projects” box on the Start Page
This is a Visual Basic
GUI object called a form
Forms are the windows
and dialog boxes that
display when a program
runs.
A form is an object that
contains other objects
such as buttons, text
boxes, and labels
Form elements are
objects called controls
This form has:
TwoTextBox controls
Four Label controls
Two Button controls
The value displayed by
a control is held in the text property of the control
Left button text property is Calculate Gross Pay
Buttons have methods attached to events
Design
T Window
Solution
o Explorer
o
l
b Properties
o Window
x
Step 1: Add a Control to the Form – Button
Look in the Toolbox for the Button Control
Select the Button with the Mouse
Draw a Rectangle Region in the Design Window
by holding the mouse button down
Release the mouse button to see your button
(Can also be added by double clicking on the
button in the Toolbox)
Add a Second Button to the Form
Put it in the lower right corner
Label1 txtHoursWorked
Label2 txtPayRate
Label3 lblGrossPay
btnCalcGrossPay btnClose
Should be meaningful
1st 3 lowercase letters indicate the type of control
txt… for Text Boxes
lbl… for Labels
btn… for Buttons
After that, capitalize the first letter of each word
txtHoursWorked is clearer than txthoursworked
Change the name property
Set the name of button1 to btnWelcome
Set the name of button2 to btnExit
Click on the Control in the Design Window
Select the appropriate property in the
Properties Window
Determines the visible text on the control
Change the text property
bntWelcome set to “Say Welcome”
btnExit set to “Exit”