Professional Documents
Culture Documents
Introduction To Computer Programming - VB
Introduction To Computer Programming - VB
Syllabus:
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 2 / 40
1) Flowcharts
• Start and end symbols, represented as ovals or rouned rectangles, usually containg
the word "Start" or "End".
• Arrows, showing what's called "flow of control" in computer science. An arrow
coming from one symbol and ending at another symbol represents that control
passes to the symbol the arrow points to.
• Processing steps, represented as rectangles. Example: Add 1 to X.
• Input/Output, represented as a parallelogram. Examples: Get X from the user;
display X.
• Conditional, represented as a diamond (rhombus). These typically contain a
Yes/No question or True/False test. This symbol is unique in that it has two
arrows coming out of it, usually from the bottom point and right point, one
corresponding to Yes or True, and one corresponding to No or False.
Flowcharts may contain other symbols, such as connectors, usually represented as circles.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 3 / 40
Flowcharts are usually drawn using some standard symbols; however, some special
symbols can also be developed when required.
IDE is an acronym for Integrated Development Environment. The IDE is the workbench
on which you make your programs in Visual Basic.
The Visual Basic IDE is a collection of menus, toolbars, and windows that make up your
programming workbench. Each part of the IDE has features that affect different aspects
of your programming activity. The menu bar lets you direct the overall activity and
management of your programming. The toolbar enables you to access much of the menu
bar's functionality through various toolbar buttons. Forms--the basic building blocks of
Visual Basic programs--are presented in a Form window. You use the ToolBox to add
controls to the forms of your project. The Project Explorer displays the projects on which
you're working, as well as the different parts of each of those projects. You browse and
set a control, form, and module's properties within the Properties window. Finally, you
position and view a form or forms onscreen within the Form Layout window. All these
properties of VB are together creating the Visual Basic Environment.
On start up, Visual Basic 6.0 will display the following dialog box as shown in the
following figure. You can choose to start a new project, open an existing project or select
a list of recently opened programs.
A project is a collection of files that make up your application. Now, click on the
Standard EXE icon to go into the actual VB programming environment. (EXE means
executable program).
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 4 / 40
a. Tool Box
b. The Form Window
c. The Code Window
d. The Project Window
e. Properties Window
f. Form Layout Window
g. Menu Bar and Tool Bar
Menu
Bar Project
Window
Control
Toolbox
Properties
Form Window
a. Tool Box
Visual basic tool box consists of objects, which are used for the programming design.
Each and every object of a toolbox is called a Control.
Pointer Picture
Label Text Box
Group Frame Command Button
Check Box Option/Radio Button
Combo Box List Box
Horizontal Scroll Bar Vertical Scroll Bar
Timer Drive List Box
Directory List Box File List Box
Shape Line
Image Data Control
OLE
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 5 / 40
The text box is the standard control that is used to receive input from the user as well as
to display the output. It can handle string (text) and numeric data but not images or
pictures. String in a text box can be converted to a numeric data by using the function
Val(text).
2 The Label
The label is a very useful control for Visual Basic, as it is not only used to provide
instructions and guides to the users, it can also be used to display outputs. One of its most
important properties is Caption. You can change its caption in the properties window and
also at runtime.
The Picture Box is one of the controls that used to handle graphics. You can load a
picture at design phase by clicking on the picture item in the properties window.
The Image Box is another control that handles images and pictures. It functions almost
identically to the picture box. However, there is one major difference, the image in an
Image Box is stretchable, which means it can be resized. This feature is not available in
the Picture Box.
The function of the List Box is to present a list of items where the user can click and
select the items from the list. In order to add items to the list, we can use the AddItem
method. For example, List1.AddItem (“Lesson1”)
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 6 / 40
The function of the Combo Box is also to present a list of items where the user can click
and select the items from the list. However, the user needs to click on the small
arrowhead on the right of the combo box to see the items which are presented in a drop-
down list. In order to add items to the list, you can also use the AddItem method. For
example, if you wish to add an item to Combo box 1, you can key in the following
statement, Combo1.AddItem “Item1”
The Check Box control lets the user to select or unselect an option. When the Check Box
is checked, its value is set to 1 and when it is unchecked, the value is set to 0. You can
include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0
unmark the Check Box, and use them to initiate certain actions.
Example
Private Sub Check1_Click ()
If Check1.Value = 0 Then
Form1.BackColor = vbRed
ElseIf Check1.Value = 1 Then
Form1.BackColor = vbBlue
End If
End Sub
The Option Box control also lets the user selects one of the choices. However, two or
more Option Boxes must work together because as one of the Option Boxes is selected,
the other Option Boxes will be unselected. In fact, only one Option Box can be selected
at one time. When an option box is selected, its value is set to “True” and when it is
unselected; its value is set to “False”.
The Drive ListBox is used to display a list of drives available in your computer. When
you place this control into the form and run the program, you will be able to select
different drives from your computer as shown in the following figure.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 7 / 40
The Directory List Box is used to display the list of directories or folders in a selected
drive. When you place this control into the form and run the program, you will be able to
select different directories from a selected drive in your computer as shown in the
following figure.
Figure. The Directory List Box
The File List Box is used to display the list of files in a selected directory or folder. When
you place this control into the form and run the program, you will be able to a list of files
in a selected directory as shown in the following figure.
You can coordinate the Drive List Box, the Directory List Box and the File List Box to
search for the files you want.
The Form window is the window or background, where the user can design his form
using various controls from the toolbox.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 8 / 40
After designing the form, the next step will be code writing. The Code window is the
place where all the coding of every form will be written.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 9 / 40
The Project Window can be used to navigate between the code and form window for each
form / window a project has.
1. Position the pointer on the white area of the Project window (not over a form or
any other item on the tree view).
2. Right-click to display the Project Explorer context menu.
3. Choose Add and then Form.
You can add or remove projects, forms, and modules to or from the Project Explorer
by using its context menu.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 10 / 40
e. Properties Window
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 11 / 40
The menu bar presents the Visual Basic menus. Here is a list of those menus and what
they do:
File - File handling and printing; also used to make EXE files
Edit - Standard editing functions, undo, searches
View - Displays or hides windows and toolbars
Project - Sets project properties, adds/removes forms and modules, and
adds / removes references and components
Format - Aligns or sizes controls
Debug - Starts/stops debugging and stepping through programs
Run - Starts a program, or compiles and starts it
Tools - Adds procedures, starts the Menu Editor, sets IDE options
Add-Ins - Add-in manager, lists add-ins like Application Wizard and API
Viewer
Window - Arranges or selects open windows
Help - Handles Help and the About box
Step1: Change the Caption and Name properties of the command button into
DisplayName
Step2: Double clicking the command button will take you to the code window, to write a
code in the click event of the DisplayName button. Write the following code:
In this code, the text value of the textbox named Text1 will be given to the Caption
property of the label box. The “+” sign is used to concatenate two strings.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 12 / 40
Visual basic has the base programming language called BASIC (Beginners All-purpose
Symbolic Instruction Code). It is a simple programming language developed in the mid
1960’s. Simplicity of BASIC made it a natural choice as a programming language.
❖ Professional edition - designed for professionals. This edition contains all that
the Learning Edition contains and more, such as the capability to write
ActiveX controls and documents. It is required for certain database
functionality
❖ Enterprise edition which is the most complete Visual Basic edition. This
edition is targeted towards professional programmers who may work in a
team and includes additional tools such as Visual SourceSafe, a version-
control system that coordinates team programming.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 13 / 40
– Label,
– etc
❖ Controls have
– Properties : determine how control looks / interacts
– Events : are things that can be done to a control
– Methods : routines which can be done to a control
2) Properties
❖ Properties describe the characteristics of a control, these can be
– physical characteristics such as height, width and colour
– or its current state such as enabled, or links definitions to other
applications
❖ Note the name and caption properties of a control have the same default values
but are actually quiet different.
– The name is what code uses to reference the control, whereas
– the caption is purely what is written on the control so the user can identify
it
❖ properties can be changed either at design time or at run time
3) Events
❖ In order to implement these blocks of code in Visual Basic
– Controls have pre-defined ‘events’ e.g. Click, Change etc
– Code can be attached to an event
– When an event occurs
i. if code has been attached it is executed,
ii. e.g when a command button is clicked using a mouse, the ‘click
event’ is invoked, so any code under the command buttons click
event is executed
iii. otherwise default processing takes place
iv. e.g. in terms of click event, if no code is attached nothing happens
Some VB events for a form object are:
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 14 / 40
Visual Basic is very...well...visual, and that includes the layout of controls in your
programs. If you’ve got a number of controls that should be aligned in a straight line, it
can be murder to have to squint at the screen, aligning those controls in a line down to the
very last pixel. Fortunately, there’s an easier way to do it:
1. Hold down the Ctrl key and click all the controls you want to align.
2. Make sure you have one control in the correct position, and click that one last. Sizing
handles, the eight small boxes that you can grasp with the mouse to resize a control,
appear around all the clicked controls.
To align all the selected controls to the same left, right, or center position of the key
control, you continue with these steps:
3. Select the Align item in the Format menu, open the Align submenu,
4. Select the type of alignment you want in the Align submenu: align the left, the center,
the right, the top, the middle, or the bottom edges of the controls with the key control.
5. While the controls are still collectively selected, you can move them, if you like, as a
group to any new location now that they are aligned as you want them.
To size all selected controls the same as the key control, follow Steps 1 and 2, and then
continue this way:
3. Select the Make Same Size item in the Format menu, open that submenu
4. Choose the appropriate item in the Make Same Size submenu to size the controls
as you want them: matching the key control’s width, height, or both.
To space multiple controls vertically or horizontally, follow Steps 1 and 2 and then
continue:
3. Select the Horizontal Spacing or Vertical Spacing item in the Format menu,
open that submenu.
Spacing controls.
4. To space the controls horizontally or vertically, select one of the items in the
corresponding submenu:
" Make Equal_Sets the spacing to the average of the current spacing
" Increase_Increases by one grid line
" Decrease_Decreases by one grid line
" Remove_Removes spacing
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 15 / 40
Saving a VB project
❖ The best way to organise your projects is by keeping each project in a separate
directory on your floppy disk.
❖ When you come to save the project you will be saving a number of files:
– FORM1.FRM the form itself
– MODULE. BAS module file if any
– PROJECT1.VBP the project file
❖ If you select ‘Save Project’ from the ‘File’ Menu, it will save all your files
Constants are values which will not be changed through out the program. Use
constants and declare them all in one place, then refer to the constants by name
throughout the code instead of hardwiring numeric values in the code.
The Public keyword is used at the module level to make a constant global. The
Private keyword is used at the module or form level to declare constants that are
private, which means only available within the module or form where the declaration
is made. These keywords are not allowed in procedures. (constants in procedures are
always private anyway).
The constname identifier is the actual name of the constant. The type identifier is the
data type of the constant, which may be Integer, Long, Currency, Single, Double,
Date, String, etc. The expression identifier holds the value you want for this
constant.
When you want to modify the value of the constant, you only have to change it in its
declaration, not in many places around the program. Also, constants don’t change
their values.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 16 / 40
Example:
C=10 ‘ here C is a numeric constant
A=”UNR” ‘ here A is an string constant
Variables are some user defined names which can be given different values by the
user in the same program. The Dim statement is used in VB to declare variables.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 17 / 40
Arithmetic operators
These operators are used to perform mathematical calculations.
Comparison operators
These are operators which are used to compare two numbers, names, etc.,
> greater than
< less than
= is equal to
>= is greater than or equal to
<= is less than or equal to
<> is not equal to
Example:
If ( Age = 10 ) Then
If ( Marks >= 40 ) Then
6. Simple Programs
Exercise 1:
Program using Check Box and Option Button.
Controls:
Place the following controls in your form and change the below mentioned
properties as shown in the table.
Control Name Caption
Label Box Label1 Degree
Label Box Label2 Courses
Text Box Text1
Option Button Option1 Bachelor
Option Button Option2 Master
Option Button Option3 Doctor
Check Box Check1 C++
Check Box Check2 Java
Check Box Check3 VB
Command Button ResultOfOption ResultOfOption
Command Button ResultOfCheck ResultOfCheck
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 18 / 40
Coding:
If Check2.Value = 1 Then
Text1.Text = Text1.Text + " Java is selected"
Else
Text1.Text = Text1.Text + " Java is not selected"
End If
If Check3.Value = 1 Then
Text1.Text = Text1.Text + " VB is selected"
Else
Text1.Text = Text1.Text + " VB is not selected"
End If
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 19 / 40
Exercise 2:
Program using Frames.
Controls:
Place the following controls in your form and change the below mentioned
properties as shown in the table.
Frame Frame2 AS
Inside Frame2 create the following controls
Label Box Label5 Computer Science
Label Box Label6 Electronics .
Label Box Label7 Civil Engineering
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 20 / 40
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 21 / 40
Exercise 3:
Program using Combo Box and List Box.
Controls:
Place the following controls in your form and change the below mentioned
properties as shown in the table.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 22 / 40
Exercise 4:
Creating menus in VB
Menu Shortcut
bar s
Cascading Checked
Menus option
Separator Disabled
bar Options
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 23 / 40
Caption, to go on
menu
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 25 / 40
Example:
Objective of the program:
To change the background colour of the form when depends on the menu item
you click.
Menu items
Create menus and submenus as directed below using the Menu Editor
Color
…FormColor
……Red
……Blue
……Green
Window
….Close
Coding
7. Control Structures
i) If….then
If condition Then {actions when condition is TRUE}
Example:
If Marks<40 Then Result = "Fail"
Block form:
If there are many lines under a if statement they can be written inside if block.
This type of block if always requires an endif.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 26 / 40
If condition Then
{action 1 when condition is TRUE}
{actions ... when condition is TRUE}
End If
Example:
If (iMarks<40) Then
Example:
If Marks<40 Then Result= "Fail" Else Result = "Pass"
Block form:
If ( condition ) Then
{actions ... when condition is TRUE}
Else
{actions ... when condition is FALSE}
End If
Example:
If (iMarks<40) Then
Result = "Fail"
Grade = “B”
Else
Result = "Pass"
Grade = “A”
End If
Select Case is similar to if statements but simpler than that. The simplest form of
the Select statement is:
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 27 / 40
Example:
Code=4
Select Case Code
Case 1
form1.backcolor=QBColor (1)
Case 2, 3, 4
form1.backcolor=VbRed
Case 5 To 7
Form1.backcolor=RGB (0, 255, 0)
End Select
Do Loop
– Do Loop structure is used to perform a statement (or set of statements) one
or more times, depending on whether the condition at the top or bottom of
the loop is true or false.
– There are a number of forms of the Do...Loop:
– There are two variations of the Do…Loop statements and both use the
same basic model. A loop can be executed either while the condition is
True or until the condition becomes true.
– These two variations use the keywords While and Until.
– To execute a block of statements while a condition is True, While is used
with DO where as to execute a block of statements until the condition
becomes True, Until is used with Do.
iv) Do while….Loop
Do While condition
statements
Loop
Example:
Sub Command1_Click ()
Dim iCount As Integer
iCount = 100
Do While iCount > 0
Print "iCount = "; iCount
iCount = iCount – 10
Loop
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 28 / 40
v) Do Until….Loop
Do Until condition
statements
Loop
Example:
Sub Command1_Click ()
Dim iCount As Integer
iCount = 100
Do Until iCount < 0
Print "iCount = "; iCount
iCount = iCount – 10
Loop
End Sub
Do
statements
Loop While condition
Example:
Sub Command1_Click ()
Dim iCount As Integer
iCount = 100
Do
Print "iCount = "; iCount
iCount = iCount – 10
Loop while iCount > 0
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 29 / 40
❖ It should be used when you know how may times the loop should be executed
before entering the loop
❖ General structure:
❖ Unless a Step is specified the For loop will increment by 1 each time
❖ We can also specify the step size and count backwards:
Example:
Sub Command1_Click ()
Dim iCount As Integer
For iCount = 100 To 0 Step -10
Print "iCount = "; iCount
Next iCount
End Sub
The above examples of different kind of loops are to produce the following result.
8) Sub Procedures
Procedures are useful for implementing repeated tasks, such as frequently used
calculations. If there are some statements that are needed to be repeated many times in a
program, those statements can be written only once as a separate procedure and can be
called anywhere inside the program for any number of times.
❖ Sub-Procedure Structure:
Parameters
Sub subname(value1 As type, Value2 As type, etc)
declarations (local)
statements
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 30 / 40
❖ Calling: Arguments
Call subname(value1, value2, etc)
or
subname value1, value2, etc
Exercise
Program using a Procedure
Controls:
Place the following controls in your form and change the below mentioned
properties as shown in the table.
Coding:
Write the following codes in the code window.
The above codes will be executed when the respective command buttons are
clicked. This code executes Multiply procedure.
You have to now add a new procedure to your form and have to name it Multiply.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 31 / 40
v. Now the following code should be added between the parenthesis of the
first line of the Multiply procedure as follows.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 32 / 40
9) Function Procedures
Exercise
Follow the same steps of the exercise for adding Procedure to design the form and
include some small changes in the code window (with Add Procedure dialog box and in
the code for the command buttons) as instructed below.
Coding
The above codes will be executed when the respective command buttons are
clicked. This code executes Multiply function.
You have to now add a new function to your form and have to name it Multiply.
To add a new function, follow the same steps of adding procedure except
choosing the type.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 33 / 40
For adding functions, the Type of the Add Procedure dialog box should be
choosen as Function.
10) Strings
Example:
Dim Str as String ‘Str is a string variable which can hold only text value
We can assign any text to the variable Str. We can store nearly 2GB of text in a string
variable. The values of a string variable must always be enclosed by double quotes. The
following assignments are example for some valid string values.
Str = “WELCOME”
Str = “1500”
Str = “Good Morning to Everybody”
i) Trim
• The Trim() function returns the string without the leading and trailing
spaces.
• The LTrim() funtction returns the string without the leading spaces.
• The RTrim() function returns the string without the trailing spaces.
Examples:
Private Sub Command1_Click()
Dim Str As String
Str = " Welcome to NUR "
Print "ResultOfTrim =" + Trim(Str)
Print "ResultOfLTrim =" + LTrim(Str)
Print "ResultOfRTrim =" + RTrim(Str)
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 34 / 40
ii) Left$
Left$() function is used to extract a substring from the left of the given
string. The parameter is used to say the number of characters to be
extracted.
iii) Right$
Right$() function is used to extract a substring from the right side of the
given string. The parameter in this function is used to tell the number of
characters to be extracted from the right side of the string.
iv) Mid$
Mid$() function is used to extract a substring from the middle of the given
string. In this function two parameters are used. The first is used to tell the
starting character and the second is to tell the number of characters to be
extracted from the first parameter.
Example:
Private Sub Command1_Click()
Dim Str As String
Str = "Welcome to NUR"
Print "Result Of Left$=" + Left$(Str, 3)
Print "Result Of Right$=" + Right$(Str, 6)
Print "Result Of Mid$ =" + Mid$(Str, 4, 7)
End Sub
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 35 / 40
11) Arrays
A single variable name holding a set of similar values is called array. An array variable
can be declared in a general declaration or a procedure or in a module. We need to say
what the size of the array is when we declare it.
Example:
Dim Count(10) As Integer ‘ an integer array which can store 10 numbers
Dim Names(5) As String ‘ a string array that can hold 5 names
We need to be able to address the individual elements in an array. For that we use the
array name and the element number to access it.
What is a Database ?
❖ A Database is a store of information
❖ Databases are divided into one or more tables
❖ Each table consists of a series of records
❖ Each record contains a number of distinct fields
What is a Field ?
❖ Fields are a store for an individual item of data
e.g. they may contain someones name or their age
❖ For example an name field could contain the name “Jeremy”
❖ Or an age field could contain the number 18
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 36 / 40
What is a Record ?
❖ A Record is a collection of fields , which describe some entity
❖ For example a book can be described as having a
– Title
– Author
– ISBN
Book Record
What is a Table ?
Table of books
Title Author ISBN Publisher
Oliver Charles Dickens 012-9877-5643 McGraw Hill
VB Design John Smith 230-7692-1287 Prentice Hall
: :
: :
: :
: :
Pasta Fasta Gill Jones 890-6023-5028 Penguin
Multiple Tables
❖ Databases are made up of one or more tables
❖ Databases should be divived into tables containing a related type of data e.g.
A company could have a staff database, split into tables as below for different
departments to access
Access Connectivity
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 37 / 40
• VB includes a control object called the Data Control which acts as a ‘bridge’
between VB and Access.
• This permits information from a database to be linked with normal objects on a
form e.g. text boxes, labels etc.
• This linking includes three major steps.
• Creating an Access database (we can also use a database which already
exists)
• Design the Visual Basic form according to the fields of the Access
database you want to connect.
• Connecting the VB form to the Access database using Data Control.
Creating an access database from the Visual Basic interface includes the following steps.
• This action will display the create database window, where you have to type the
database name.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 38 / 40
• In the database window, right click and click New Table, give a name for your
table to create a new table and to add fields for that table.
• After creating the necessary fields for the table click Build the table to construct
• Once the table is created double click on the table name to open the table and data
can be added to that table by clicking the add and update buttons.
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 39 / 40
• Once the data control has been initialized it is possible to access the information.
• No VB code is required, only the use of the properties window.
• E.g. to display the value of a field from the DB in a text box:
• add a text box to the form
• select the properties window
• set the DataSource to the name of the data control
• set the DataField to the field in question from the DB.
Manipulating Databases
Auxeeliya, Ashraph
Dept. of Computer Science
Introduction to Computer Programming (Visual Basic) 40 / 40
Auxeeliya, Ashraph
Dept. of Computer Science