Practical File of Visual Basic
Practical File of Visual Basic
Design-
Coding-
Private Sub CommandI_Click()
Dim a As
Integer Dim b
As Integer a =
Textl.Text b =
Text2.Text
Text3.Text = a - b
End Sub
Private Sub Command2_
Dim a As
Integer Dim b
As Integer a =
Textl.Text
b • Text2.Text
Text3.Text a + b End
Sub
Private Sub
Dim a As
Integer Dim b
As Integer a
Textl.Text b
Text2.Text
Text3.Text= a • b
End Sub
Private Sub
Dim a As Integer
Dim b As Integer
a = Textl.Text b =
Text2.Text
Text3.Text = b
End Sub
Output-
2) Wap to calculate biggest number from array
Design-
Coding-
Private Sub Command1_Click()
Dim s(l To 10) As Integer
Dim i As Integer Dim
greater As Integer Dim a
As Integer a =
InputBox("enter array")
For i = 1 Toa s(i) =
InputBox("array are")
Print s(i)
Next i
greater = s(l)
For i = 1 Toa
If greater s(i) Then
greater • s(i) End If
Next i Print
greater
End Sub
Output-
Output-
3) Wap to show check box
Designs-
Coding-
Private Sub Checkl_Click()
If Checkl.Value = 1 Then
Textl.Font.Bold = True
Else
Textl.Font.Bold
End If
End Sub
Private
Sub Check2_Click()
If Check2.Value = i Then
Textl.Font.ltalic = True
Else
Textl.Font.ItaIic = False
End If
End Sub
Design-
Coding-
Private Sub Command1_Click()
Dim area As Integer
Const pi 3.14 area = pi *
Textl.Text * Textl.Text
MsgBox (area)
End Sub
5) Calculate factorial of number
Design-
Coding-
Coding-
Dim f As Integer
Dim c As Integer
f =
VScr0111.Value
Textl.Text = f
Text2.Text = c
End Sub
Output-、
series
Coding-
n = InputBox("enter a number")
For i = ITO n
If i 1 Then
nxt = i
Else
nxt S + SI
Sl nxt End
If
Print nxt
Next i
End Sub
Output-
8) WAP To show imagelist and viewlist
Design-
Coding-
End sub
Output-
9) WAP To Show Linear Search
Design-
Coding-
Private Sub Command1_ClickO
Dim 10) As Integer
Dim i As Integer
Dim s As Integer
For i = O To 4 a(i)
numbers")
Print a(i)
Next i
Fori=OT04
If a(i) = Textl.Text Then
Design-
Coding-
Check2,VaIuo
Check3 Value
Check4 Value
End Sub
Private Sub
Checkl,Value O
Check1,Value2
Check3.Value O Check4,Value1
End Sub
Output-
11) WAP To Show Palindrome of a Number
Design-
Coding-
Output-
12) WAP To Show is Prime Number
Design-
Coding-
Private Sub CommandI_CIick()
Dim n As Integer
Dim i As Integer
Dim p As Integer
n InputBox("enter a no.")
Fori=2 Ton-I
If (n Mod i = O) Then
End If
Next i
If p = 1 Then
sgBox ("not a prime no.")
Ise sgBox ("prime
no.")
End If
End Sub
Output-
13) WAP To Write an Application Using
Progress Bar
Design –
Coding-
privateSubTimer1_Timer()
progressBar1.Value = ProgressBar1.Value +
1
Labell.Caption=ProgressBar1.Value&
"'completed"
If ProgressBar1,Value 100 Then
End
End If
End Sub
Output-
14) Wap to show reverse of a number
Design-
Coding-
Private Sub CommandI_Click()
Dim i As Integer
Dim s As Integer Dim rvrs As Integer
rvrs = O
i = Val(Text1.Text) While (i o O)
Mod 10
rvrs = rvrs * 10 + s
Wend
Text2.Text rvrs
Print rvrs
End Sub
Output -
15) WAP To Show Rich Textuboxes
Design-
Desig
Coding-
Private Sub cmdcolor_Click()
CommonDialog1.showcolor
RichTextBox1.SelColor = CommonDialog1.Color End Sub
End Sub
Output-
16) WAP To write an application using slider
control
Design-
Coding-
Private Sub Slider1_Click()
Labell.Caption = Slider1.Value
End Sub
Output-
17) WAP TO Write Application Using Status Bar
Design-
Coding-
Private Sub StatusBar1_PanelClick(ByVal Panel As
MSComctlLib.Panel)
MsgBox ("This is a status bar")
End Sub
Output-