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
‘option for multiplication
Private Sub Option3_Click() a = Val(Text1.Text) b = Val(Text2.Text) c = a * b
Text3.Text = c
Label4.Caption = "Multiplication of two given number ="
End Sub
‘option for division
Private Sub Option4_Click() a = Val(Text1.Text) b = Val(Text2.Text) c = a / b
Text3.Text = c
Label4.Caption = "Division of two given number ="
End Sub
‘option for modulas
Private Sub Option5_Click() a = Val(Text1.Text) b = Val(Text2.Text) c = a Mod b
Text3.Text = c
Label4.Caption = "Modulus of two given number ="
End Sub
Practical 2
Aim :- WAP to take input of principal, rate & time and calculate simple interest & compound interest.
Design:-
Source code:-
Path:- E:\Documents and Settings\ss\Myfiles
‘variable declaration globally
Dim SI, CI, P, R, T, AMT, I, EXP As Double
‘command for clear textbox
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Visible = False
Label5.Visible = False
End Sub
‘command for exit from program
Private Sub Command2_Click()
End
End Sub
‘set height and width of form
Private Sub Form_Load()
Label5.Visible = False
Text4.Visible = False
Form1.Width = 15000
Form1.Height = 8500
End Sub
‘calculate simple interest
Private Sub Option1_Click()
Label5.Visible = True