program
to make simple calculator
------------------------------------------------code------------------------------------------------------
Public Class Form1
Dim a, b As Double
Dim ans As String
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button1.Click
TextBox1.Text = TextBox1.Text +
Button1.Text
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = TextBox1.Text +
Button2.Text
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button3.Click
TextBox1.Text = TextBox1.Text +
Button3.Text
End Sub
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button5.Click
TextBox1.Text = TextBox1.Text +
Button5.Text
End Sub
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button6.Click
TextBox1.Text = TextBox1.Text + Button6.Text
End Sub
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button7.Click
TextBox1.Text = TextBox1.Text +
Button7.Text
End Sub
Private Sub
Button9_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button9.Click
TextBox1.Text = TextBox1.Text +
Button9.Text
End Sub
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button10.Click
TextBox1.Text = TextBox1.Text +
Button10.Text
End Sub
Private Sub
Button11_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button11.Click
TextBox1.Text = TextBox1.Text +
Button11.Text
End Sub
Private Sub
Button13_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button13.Click
TextBox1.Text = TextBox1.Text +
Button13.Text
End Sub
Private Sub
Button14_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button14.Click
TextBox1.Text = TextBox1.Text +
Button14.Text
End Sub
Private Sub
Button16_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button16.Click
If
TextBox1.Text <> "" Then
a = TextBox1.Text
ans = "+"
End If
TextBox1.Text = ""
End Sub
Private Sub
Button12_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button12.Click
If
TextBox1.Text <> "" Then
a = TextBox1.Text
ans = "-"
End If
TextBox1.Text = ""
End Sub
Private Sub
Button8_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button8.Click
If
TextBox1.Text <> "" Then
a = TextBox1.Text
ans = "*"
End If
TextBox1.Text = ""
End Sub
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button4.Click
If
TextBox1.Text <> "" Then
a = TextBox1.Text
ans = "/"
End If
TextBox1.Text = ""
End Sub
Private Sub
Button15_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
Button15.Click
If
TextBox1.Text <> "" Then
b = TextBox1.Text
End If
Select Case ans
Case
"+"
TextBox1.Text = a + b
Case
"-"
TextBox1.Text = a - b
Case
"*"
TextBox1.Text = a * b
Case
"/"
If
b <> 0 Then
TextBox1.Text = a / b
Else
TextBox1.Text = "E"
End
If
End Select
End Sub
Private Sub Button17_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button17.Click
TextBox1.Text = ""
End Sub
End Class
-----------------------------------------------output-----------------------------------------------------
umesh sohaliya |
No comments:
Post a Comment