Professional Documents
Culture Documents
Programs:-
Visual Basic
a) Forms
b) Controls
The icons with which the user interacts are called controls.
c) Objects
d) Properties
e) Methods
A method in VB is a predefined action that operates on a
specific object (i.e. form of control). For example, set focus
method is used to move the specific object.
Visual Basic Integrated Development Environment (IDE)
Once you start VB, several different items appear on your screen.
Together these items represent the VB Integrated Development
Environment (IDE).
Tools Box
Project explorer or simply project window
Properties Window
Form layout window
Title Bar
Menu Bar and pull down menus
Toolbar
Form Designer
Immediate Window
Controls
The input box function s used to read data from the user.
This function displays a dialog box that asks the user to
enter some data.
Where
Msgbox(prompt[,button][,title][,helpfile, context])
Where
Help field and Context File has been set up to work with
the application.
Loop Statements
For-next
For each-next
While-wend
Do-Loop
Syntax:
Statement(s)
Next counter
Here the start and end are the initial and final values of the
variable counter. Initially the value of counter is set to
start and it increase by 1 each time the loop is executed,
until it reaches end. Here the next statement identifies the
end of the loop.
Statement(s)
Next element
Syntax:
While Condition
Statements
Wend
Syntax:
Do while condition
Statements
Loops
Do-Loop While:
Syntax:
Do
Statements
Syntax:
Do until condition
Statement(s)
Loop
Do-loop until:
Syntax:
Do
Statement(s)
If Check1.Value = 1 Then
Text1.FontBold = True
Else
Text1.FontBold = False
End If
End Sub
If Check2.Value = 1 Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
End Sub
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub
If Check4.Value = 1 Then
Text1.FontStrikethru = True
Else
Text1.FontStrikethru = False
End If
End Sub
Text1.Text = ""
End Sub
Private Sub Command2_Click()
End
End Sub
Text1.ForeColor = RGB(255, 0, 0)
Else
Text1.ForeColor = RGB(0, 0, 0)
End If
End Sub
Else
Text1.ForeColor = RGB(0, 0, 0)
End If
End Sub
Else
Text1.ForeColor = RGB(0, 0, 0)
End If
End Sub
Output:-
Program to display grade using switch case
marks = Val(Text1.Text)
Case 80 To 100
grade = "A"
Case 60 To 79
grade = "B"
Case 50 To 59
grade = "C"
Case 40 To 49
grade = "D"
Case 0 To 39
grade = "E"
End Select
End
End Sub
Program to find greatest number between three numbers
Else
End If
End Sub
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
End
End Sub
End Sub
End Sub
End Sub
End Sub
Output:-
Program to show the use of drive box, directory box,
file box.
End
End Sub
File1.Path = Dir1.Path
End Sub
Dir1.Path = Drive1.Path
End Sub
Dim y As String
End Sub
Private Sub Image1_Click()
Image1.Picture = LoadPicture(y)
End Sub
Program of Stopwatch using Timer
End
End Sub
Timer1.Enabled = False
ss.Caption = "00"
mm.Caption = "00"
hh.Caption = "00"
End Sub
Timer1.Enabled = True
End If
End Sub
Private Sub cmdstop_Click()
Timer1.Enabled = False
End Sub
End Sub
End Sub
End Sub
If ss.Caption = 60 Then
ss.Caption = 0
mm.Caption = 0
End If
End Sub
Program to draw Different Shapes
Shape1.Visible = False
Line1.Visible = True
Line1.BorderStyle = 1
End Sub
Line1.Visible = False
Shape1.Visible = True
Shape1.Shape = 3
End Sub
Line1.Visible = False
Shape1.Visible = True
Shape1.Shape = 1
End Sub
Private Sub Command4_Click()
Line1.Visible = False
Shape1.Visible = True
Shape1.Shape = 2
End Sub
Program to design a Simple Calculator
op1 = Val(Text1.Text)
End Sub
op2 = 0
op1 = 0
Text1.Text = ""
End Sub
op1 = 0
Text1.Text = ""
End Sub
Case "+"
tetx1.Text = result
Case "-"
tetx1.Text = result
Case "*"
tetx1.Text = result
Case "/"
tetx1.Text = result
End Select
op1 = result
End Sub
Text1.Text = ""
op2 = op1
op1 = 0
operator = Command1(Index).Caption
End Sub
End
End Sub
Output:-
A
Practical File
On
Visual Basic
Roll No: