How to make your own calculator in vb.net?
Step1:
Open Microsoft visual studio
Step2:
File ànew project àselect the windows form application àrename it as calculator
Step3:
Drag and drop
Textbox1, textbox2, label1
Button1
|
+
|
Button2
|
-
|
Button3
|
/
|
Button4
|
*
|
Button5
|
1/x
|
Change the font style for all buttons if you need
Code:
Public Class Form1
Private SubButton1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
Private SubButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton2.Click
Label1.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub
Private SubButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton4.Click
Label1.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
End Sub
Private SubButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton3.Click
Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private SubButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton5.Click
TextBox2.Text = ""
Label1.Text = 1 / Val(TextBox1.Text)
End Sub
End Class
you can add more buttons for another operation
No comments:
Post a Comment