Modul Visual Basic
Modul Visual Basic
INTRODUCTION TO
Visual Basic 6.0
What is a Toolbox?
The toolbox contains the controls that you
place on the Form Window. All the
controls appear on the toolbox.
Label
Text
Text
Com Boxmand
Box
Button
Command Button
Number 1
Click on
ADD
• Label
– A label control is used to display text that a user can’t
change directly.
• Textbox
– A textbox control is used to input data from the user at run
time.
• Command button
– A command button is used to perform an event at run
time.
Operator Meaning
= Equal to
> Greater than
< Less Than
< Not Equal to
>
• The conditional operators compares data
values and then decide what action to take.
Copyright Mr.Anjan Mahanta LCCT International Studies 26
Examples
A=10, B=15
Operations Result
?
Is A=B FALSE / NO
?
Is A>B FALSE / NO
?
Is A<B TRUE / YES
?
Is A< >B TRUE / YES
If conditions Then
VB expressions
Else
VB expressions
End If
Text Box
Command Button
Label1
Option 1 Option 4
Option 2 Option 5
Option 3 Option 6
• Example 1
Msgbox “Sorry !!”, vbcritical, “Error”
• Example 2
Msgbox “Correct Password”, vbinformation, “Check”
Lab
Text Command
el
Box Button
List Box
End Sub
Timer
Lab
el
Interval
600
Label
Text
Box
Comma
nd
Button
Copyright Mr.Anjan Mahanta LCCT International Studies 103
Code
• Double click on Command Button1 Login
Private Sub Command1_Click()
Dim password As String
password = “lcct”
If Text1 = password Then
password = MsgBox(“You have passsed security!!”, vbOKOnly +
vbExclamation, “Access Granted”)
Else
password = MsgBox (“Incorrect Password!!”, vbRetryCancel +
vbCritical, “Access Denied”)
If password = vbRetry Then
Text1 = ""
Text1.SetFocus
End If
End If
End Sub
Text Box
Label
Frame
Option
Button
Combo Box
Menu Caption
Menu Name
Step 2
• Design the following form in VB
Text Box
Data
S_Code Number
Name Text
G_Vb Text
G_Data Text
structur T
e e
G_P_A x
t
Copyright Mr.Anjan Mahanta LCCT International Studies 138
Design the form grade in VB
FieldName DataType
Code Autonumber
Name Text
Score Number
• Select Data1
• In the property of Data1,
• Database name Quiz
• Recordsource Computer_Quiz