How to create a calculator in Visual Basic.
Step 1 : Start Visual Basic by,
Step 2: Drag 3 text boxes, 3 labels, and 4 buttons from the toolbox and arrange then as shown,
Step 3:
Public Class Form1
Private Sub Button1_Click(By Val sender As System. Object, By Val e As System.EventArgs ) Handles Button1.Click
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A + b
tetxbox3.text = c
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A - b
tetxbox3.text = c
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A * b
tetxbox3.text = c
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A / b
tetxbox3.text = c
End Sub
End Class
https://www.youtube.com/watch?v=LaY5BdeSN5k
- Click Start ---> All programs ---> Microsoft Visual Studio 2010 Express ---> Microsoft Visual Basic 2010 Express.
- The start page of the Microsoft Visual Basic 2010 Express appears. It consists of these sections.
- New Project / Open Project
- Recent Project
- Get Started Pane: Has useful tips to develop an application quickly.
- Latest News Pane: News about new releases and updates from Microsoft.
- To create an application , click on the "New Project". The new project window appears. At the bottom of this window, change the default project name Windows Application 1 to a more meaningful name, and click OK.
- The Integrated Environment window appears.
Step 3:
- Then double click on the "add" button and type ,
Private Sub Button1_Click(By Val sender As System. Object, By Val e As System.EventArgs ) Handles Button1.Click
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A + b
tetxbox3.text = c
End Sub
- Then double click on "Subtract" button and type,
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A - b
tetxbox3.text = c
End Sub
- Then double click on "Multiply" button and type,
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A * b
tetxbox3.text = c
End Sub
- Then double click on "Divide" button and type,
Dim A,B,C As Integer
A = Val(TextBox1.Text)
B = Val(TextBox2.Text)
C = A / b
tetxbox3.text = c
End Sub
End Class
https://www.youtube.com/watch?v=LaY5BdeSN5k
Comments
Post a Comment