Visual Basic Practical File

3294 Words14 Pages
Practical 1

Aim: - WAP to perform arithmetic operation using command buttons. (Declare variables globally).

Design:-

Source code :-

Path :- F:\Program Files\Microsoft Visual Studio\COMMON\IDE\IDE

‘Initialize variable global
Dim a, b, c As Integer
‘event for clear content
Private Sub Command1_Click()
‘clear text box
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""

End Sub

‘option for addition
Private Sub Option1_Click() a = Val(Text1.Text) b = Val(Text2.Text)
‘Perform operation c = a + b
Text3.Text = c
Label4.Caption = "Addition of two given number ="
End Sub
‘option for sub
Private Sub Option2_Click() a = Val(Text1.Text) b = Val(Text2.Text) c = a - b
Text3.Text = c
Label4.Caption = "Subtraction of two given number ="
End Sub
…show more content…
is prime or not. (Using for loop & Exit for) Design :-

Source code:-

Path:- E:\bca practical list\generateprime\ Private Sub Command1_Click()
Dim I, N As Integer
N = Val(Text1.Text)
For I = 2 To N – 1 ‘ start loop
If N Mod I = 0 Then
‘Print message
Print "THE NUMBER IS NOT A PRIME NUMBER"
Exit Sub
End If
Next I ‘ end for loop
Print "THE NUMBER IS A PRIME NUMBER"
End Sub ‘ clear contents of text box
Private Sub Command2_Click()
Text1.Text = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub

Practical 7

Aim :- Design an interface, which will appear like marksheet. It will take input of marks in five subjects and calculate total marks and percentage then provide grade according to following criteria. (Using nested if) (Use tab index property to move focus).
If % Then Grade
> = 90 A+
> = 75 & < 90 A
> = 60 & < 75 B
> = 45 & < 60 C
Otherwise F

Design :-

Source code :-

Path:- D:\MyDocuments\All
Open Document