Professional Documents
Culture Documents
Insert 2 textboxes, one label and four command buttons then write the
program to compute the sum, difference, product, division of two no. that
are entered into the text boxes and display the result in the label.
Private Sub add_procedure()
Dim res As Integer
res=Val(Textbox1.text)+Val(Textbox2.text)
Label1.Caption="Result:"&res
End
>>>>USING FUNCTIONS<<<<
Private Sub add_function() As Integer
Dim a As Integer
a=Val(TextBox1.text)+Val(TextBox2.text)
Return a
End
Private sub diff_function() As Integer
Dim a As Integer
a=Val(Textbox1.text)-Val(Textbox2.text)
Return a
End
Private Sub multi_function() As Integer
Dim a As Integer
a=Val(Textbox1.text)*Val(Textbox2.text)
Return a;
End
Private Sub div_function() As Float
Dim a As Float
a=Val(Textbox1.text)/Val(Textbox2.text)
Return a
End
Public Sub Button1_Click()
Dim res As Integer
res=add_function()
Label1.caption="Result:"&res
End
Public Sub Button2_Click()
Dim res As Integer
res=diff_function()
Label1.caption="Result:"&res
End
Public Sub Button3_Click()
Dim res As Integer
res=multi_function()
Label1.caption="Result:"&res
End
Public Sub Button4_Click()
Dim res As Float
res=div_function()
Label1.caption="Result:"&res
End