0% found this document useful (0 votes)
22 views50 pages

Visual Basic Programming Examples

The document contains a series of Visual Basic coding examples for various applications, including arithmetic operations, finding the largest number in an array, and checking for palindromes. Each section includes design and coding snippets, demonstrating different functionalities such as using checkboxes, calculating areas, and implementing progress bars. The document serves as a guide for creating simple applications using Visual Basic programming language.

Uploaded by

ashishbiganiya73
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views50 pages

Visual Basic Programming Examples

The document contains a series of Visual Basic coding examples for various applications, including arithmetic operations, finding the largest number in an array, and checking for palindromes. Each section includes design and coding snippets, demonstrating different functionalities such as using checkboxes, calculating areas, and implementing progress bars. The document serves as a guide for creating simple applications using Visual Basic programming language.

Uploaded by

ashishbiganiya73
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1) Wap to show arithmetic operator

Design-

Coding-
Private Sub CommandI_Click()
Dim a As
Integer Dim b
As Integer a =
[Link] b =
[Link]
[Link] = a - b
End Sub
Private Sub Command2_

Dim a As
Integer Dim b
As Integer a =
[Link]
b • [Link]
[Link] a + b End
Sub

Private Sub
Dim a As
Integer Dim b
As Integer a
[Link] b
[Link]
[Link]= a • b
End Sub

Private Sub
Dim a As Integer
Dim b As Integer
a = [Link] b =
[Link]
[Link] = 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 [Link] = 1 Then
[Link] = True
Else
[Link]
End If

End Sub

Private
Sub Check2_Click()
If [Link] = i Then
[Link] = True
Else
[Link] = False
End If
End Sub

Private Sub Check3_Click()


If [Link] = I Then
[Link] = UCase([Link])
End If
End Sub

Private Sub Check4_CIick()


If [Link] = 1 Then
[Link] = True
Else
[Link] = False
End If
End Sub

Private Sub Check5_Click()


If [Link] = 1 Then
[Link] =
True
Else
[Link] =
False
End If
End Sub

Private Sub Check6_Click()


If [Link] = 1
Then
[Link] = LCase([Link])
End If
End Sub
Output-
Wap to
Design:
4) WAP To calculate area of circle

Design-

Coding-
Private Sub Command1_Click()
Dim area As Integer
Const pi 3.14 area = pi *
[Link] * [Link]
MsgBox (area)
End Sub
5) Calculate factorial of number
Design-

Coding-

Private Sub CommandI_CIick()


Dim n As Integer
Dim i As Integer Dim fct As
Integer fct=l n =
InputBox("enter a number")
Fori 1 To n
fct i Next i
Print fct
End Sub
Output-
6) Convert Fahrenheit to Celsius
Design-

Coding-

Private Sub VScr0111_Change()

Dim f As Integer
Dim c As Integer
f =
[Link]
[Link] = f

[Link] = c
End Sub
Output-、
series

Coding-

Private Sub CommandI_Click()


Dim s As Integer
Dim sl As Integer
Dim nxt As Integer
Dim n As Integer
Dim i As Integer

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-

Private Sub Form_Load()


Dim iteml As Listltem
Dim item2 As Listltem
Set item2 =
[Link]
[Link] = "Tree" [Link] =
2
Dim item3 As Listltem Set item3 =
[Link]
[Link] "Waterfall" [Link] =
3

Set iteml = [Link] [Link] =


"Forest" [Link] =

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) = [Link] Then

MsgBox (enumbr is found")


End tf
ext i s = 0 Then sgBox
("number is not found") nd If
End Sub
Output-
10) Wap to show option box

Design-

Coding-

Private Sub Option1_Click()


[Link] = 1
[Link] = O
[Link] = 1
[Link] = 1
End Sub

Private Sub Option2_Click()


[Link] = O
[Link] = O
[Link] = I

Check2,VaIuo
Check3 Value
Check4 Value
End Sub

Private Sub
Checkl,Value O

Check1,Value2
[Link] O Check4,Value1
End Sub
Output-
11) WAP To Show Palindrome of a Number

Design-

Coding-

Private Sub Command1_Click()


Dim digit As
Long Dim mum
As Long mum =
O Do
digit = [Link] Mod 10
[Link] = [Link] \
10
mum = mum * 10 + digit
Loop While ([Link] > O)
If mum = [Link] Then
MsgBox ("the number is a palindrome")
Else

MsgBox ("the number is not a palindrome")


End Sub

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()
[Link] = [Link] +
1
[Link]=[Link]&
"'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([Link]) While (i o O)
Mod 10

rvrs = rvrs * 10 + s

Wend
[Link] rvrs
Print rvrs
End Sub

Output -
15) WAP To Show Rich Textuboxes

Design-

Desig
Coding-
Private Sub cmdcolor_Click()
[Link]
[Link] = [Link] End Sub

Private Sub cmdfont_Click()


[Link]
[Link] = Common [Link]

End Sub
Output-
16) WAP To write an application using slider
control

Design-

Coding-
Private Sub Slider1_Click()
[Link] = [Link]
End Sub

Output-
17) WAP TO Write Application Using Status Bar
Design-

Coding-
Private Sub StatusBar1_PanelClick(ByVal Panel As
[Link])
MsgBox ("This is a status bar")
End Sub

Output-

You might also like