0% found this document useful (0 votes)
168 views16 pages

Visual Basic Program Examples

Vb Program

Uploaded by

vinayak rockzz
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)
168 views16 pages

Visual Basic Program Examples

Vb Program

Uploaded by

vinayak rockzz
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.

Create a VB program to print the word “WELCOME TO VISUAL BASIC”

CODE
Private Sub Form_Click()

Print "WELCOME TO VISUAL BASIC"

End Sub

2. Create a VB program to print your name and address

CODE
Private Sub Form_Click()

Print "HIMA P L"

Print "CHARUVILA PUTHEN VEEDU,


MOONNAMOODU"

Print "VATTIYOORKAVU-P.O,Tvm"

End Sub
3. Create a VB program to find sum of two numbers

CODE
Private Sub Form_Click()

Dim a, b, c As Integer

a=5

b = 10

c=a+b

Print c

End Sub

4. Create a VB program to find subtract of two numbers

CODE
Private Sub Form_Click()

Dim a, b, c As Integer

a = 20

b=5

c=a-b

Print c

End Sub
5. Create a VB program to find product of two numbers

CODE
Private Sub Form_Click()

Dim a, b, c As Integer

a = 10

b=5

c=a*b

Print c

End Sub

6. Create a VB program to find arithmetic calculation of two numbers

CODE
Private Sub Form_Click()
Dim a, b, c, d, e, f, g As Integer
a=4
b=5
c=a+b
d=a-b
e=a*b
f=a/b
g = a Mod b
Print c
Print d
Print e
Print f
Print g
End Sub
7. Create a VB program to add two numbers using controls.

CODE
Private Sub Command1_Click()

Dim a, b, c As Integer

a = Val([Link])

b = Val([Link])

c=a+b

[Link] = c

End Sub

8. Create a VB program to add three numbers using controls

CODE
Private Sub Command1_Click()

Dim a, b, c As Integer

a = Val([Link])

b = Val([Link])

c = ([Link])

d=a+b+c

[Link] = d

End Sub
9. Create a VB program to find total and percentage of three marks

CODE
Private Sub Command1_Click()

Dim a, b, c As Integer

Dim p As Double

a = Val([Link])

b = Val([Link])

c = Val([Link])

d=a+b+c

[Link] = d

p = d / 300 * 100

[Link] = p

End Sub

10. Create a VB program of Arithmetic Calculation using Controls


Private Sub Command1_Click()
Dim a, b, c As Integer
a = Val([Link])
b = Val([Link])
c=a+b
[Link] = c
End Sub
Private Sub Command2_Click()
a = Val([Link])
b = Val([Link])
c=a-b
[Link] = c
End Sub
Private Sub Command3_Click()
a = Val([Link])
b = Val([Link])
c=a*b
[Link] = c
End Sub
Private Sub Command4_Click()
a = Val([Link])
b = Val([Link])
c=a/b
[Link] = c
End Sub
Private Sub Command5_Click()
a = Val([Link])

b = Val([Link])

c = a Mod b

[Link] = c

End Sub
[Link] a VB program of increase and decrease of a font

CODE
Private sub command-click()
[Link]=[Link]+8
End sub
Private sub command2-click()
[Link]=[Link]-8
End sub

12. Create a VB program of interchanging colors

CODE
Private Sub Command1_Click()

[Link] = [Link]

[Link] = [Link]

[Link] = [Link]

End Sub
13. Create a VB program of interchanging pictures

CODE

Private Sub Command1_Click()

[Link] = [Link]

[Link] = [Link]

[Link] = [Link]

End Sub

14. Create a VB program to check mouse event using MsgBox

CODE
Private Sub Command1_Click()

MsgBox "Welcome to visual Basic"

End Sub

Private Sub Command2_Click()

MsgBox "EXIT"

End Sub
15. Create a VB program to change the position of an image

CODE
Private Sub Command1_Click()

[Link] = [Link] - 60

End Sub

Private Sub Command2_Click()

[Link] = [Link] + 60

End Sub

Private Sub Command3_Click()

[Link] = [Link] - 60

End Sub

Private Sub Command4_Click()

[Link] = [Link] + 60

End Sub
16. Create a VB program using shape control.

CODE
Private Sub Command1_Click()

[Link] = 0

End Sub

Private Sub command2_click()

[Link] = 1

End Sub

Private Sub command3_click()

[Link] = 2

End Sub

Private Sub command4_click()

[Link] = 3

End Sub

Private Sub command5_click()

[Link] = 4

End Sub

Private Sub command6_click()

[Link] = 5

End Sub
17. Create a VB program to find a number Odd or Even

CODE
Private Sub Command1_Click()

Dim a As Integer

a = Val([Link])

If a Mod 2 = 0 Then

[Link] = "even"

Else

[Link] = "odd"

End If

End Sub

18. Create a VB program to find an age is eligible or not eligible for voting

CODE
Private Sub Command1_Click()

Dim a As Integer

a = Val([Link])

If a >= 18 Then

[Link] = "Eligible for voting"

Else

[Link] = "Eligible for voting"

End If

End Sub
19. Create a VB program to find biggest among two numbers.
CODE
Private Sub Command1_Click()

Dim a, b As Integer

a = Val([Link])

b = Val([Link])

If a > b Then

[Link] = a

Else

[Link] = b

End If

End Sub

20. Create a VB program to find biggest among three numbers.

CODE
Private Sub Command1_Click()

Dim a, b, c As Integer
a = Val([Link])
b = Val([Link])
c = Val([Link])
If a > b And a > c Then
[Link] = a
Else
If b > a And b > c Then
[Link] = b
Else
[Link] = c
End If
End If
End Sub
21. Create a VB program to find a number POSITIVE or NEGATIVE

Private Sub Command1_Click()

Dim a As Integer

a = Val([Link])

If a > 0 Then

[Link] = "POSITIVE"

Else

If a < 0 Then

[Link] = "NEGATIVE"

Else

If a = 0 Then

[Link] = "NEITHER POSITIVE NOR NEGATIVE"

End If

End If

End If

End Sub

22. Create a VB program to find a year LEAP YEAR or NOT

CODE
Private Sub Command1_Click()
Dim a As Integer
a = Val([Link])
If a Mod 4 = 0 Then
[Link] = "LEAP YEAR"
Else
[Link] = "NOT A LEAP YEAR"
End If
End Sub
23. Create a VB program to display the NAME OF DAY using IF ELSE IF

CODE
Private Sub Command1_Click()
Dim a As Integer
a = Val([Link])
If a = 1 Then
[Link] = "SUNDAY"
Else
If a = 2 Then
[Link] = "MONDAY"
Else
If a = 3 Then
[Link] = "TUESDAY"
Else
If a = 4 Then
[Link] = "WEDNESDAY"
Else
If a = 5 Then
[Link] = "THURSDAY"
Else
If a = 6 Then
[Link] = "FRIDAY"
Else
If a = 7 Then
[Link] = "SATURDAY"
Else
[Link] = "NOT A VALID DAY"
End If
End If
End If
End If
End If
End If
End If
End Sub
24. Create a VB program to adding the sroll bars

CODE
Private Sub HScroll1_Change()

[Link] = [Link]

[Link] = [Link]

End Sub

Private Sub VScroll1_Change()

[Link] = [Link]

End Sub

25. Create a VB program to display week using select case

Private Sub Command1_Click()


Dim day As Integer
day = Val([Link])
Select Case day
Case 1
[Link] = "sunday"
Case 2
[Link] = "monday"
Case 3
[Link] = "tuesday"
Case 4
[Link] = "wednesday"
Case 5
[Link] = "thursday"
Case 6
[Link] = "friday"
Case 7
[Link] = "saturday"
Case Else
[Link] = "NOT A VALID DAY"
End Select
End Sub

You might also like