You are on page 1of 2

9.

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

Private Sub diff_procedure()


Dim res As Integer
res=Val(Textbox1.text)-Val(Textbox2.text)
Label1.Caption="Result:"&res
End

Private Sub mult_procedure()


Dim res As Integer
res=Val(Textbox1.text)*Val(Textbox2.text)
Label10caption="Result:"&res
End

Private Sub div_procedure()


Dim res As result
res=Val(Textbox1.text)/Val(Textbox2.text)
Label1.caption="Result:"&res
End

Private Sub Button1__Click()


add_procedure()
End
Public Sub Button2_Click()
difference_procedure()
End
Public Sub Button3_Click()
mult_procedure()
End
Public Sub Button4_Click()
div_procedure()
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

10. WAP to change temp from C to F


Private Sub Convert(x As Float) As Float
Dim y As Float
y=((1.5*x)/9)+32
Return y
End
Public Sub Button1_Click()
Dim f.celcius As Float
celcius=Val(Textbox1.text)
f=convert(celcius)
Label2.Caption="Farenheit:",&f
End

11. WAP to find area and perimeter


Private Sub are(x As Float,y As Float)As Float
Dim a As Float
a=x*y
Return a
End
Private Sub perimeter(x As Float, y As Float) As Float
Dim peri As Float
peri=(2*(x+y))
Return peri
End
Public Sub Button1_Click()
Label3.caption=area(Valuebox1.text,ValueBox2.text)
Label4.caption=perimeter(ValueBox1.text,ValueBox2.text)
End

You might also like