I wanted to test if my calculator would work so I did a basic test with division and I seem to always get a result as 0 when I divide two #'s.
Line 106 starts the division code and line 140 may also be of interest.
I used a modulus because in the future I want the program to be able to allow the user to do continued operations while temporarily storing numbers in two different variables. The variable that the number is stored in is determined by if the loop index # is divisible by 2 or not.
Line 106 starts the division code and line 140 may also be of interest.
I used a modulus because in the future I want the program to be able to allow the user to do continued operations while temporarily storing numbers in two different variables. The variable that the number is stored in is determined by if the loop index # is divisible by 2 or not.
Public Class Form1
Dim index As Integer = 0
Dim stream1, stream2 As Double
Dim add As Boolean = False, subtract As Boolean = False, multiply As Boolean = False,
division As Boolean = False, power As Boolean = False, root As Boolean = False
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
txtStreamBox.Text += "1"
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
txtStreamBox.Text += "2"
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
txtStreamBox.Text += "3"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
txtStreamBox.Text += "4"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
txtStreamBox.Text += "5"
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
txtStreamBox.Text += "6"
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
txtStreamBox.Text += "7"
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
txtStreamBox.Text += "8"
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
txtStreamBox.Text += "9"
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles period.Click
txtStreamBox.Text += "."
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button0.Click
txtStreamBox.Text += "0"
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plus.Click
add = True
stream1 = Val(txtStreamBox.Text)
txtStreamBox.Text = ""
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles minus.Click
subtract = True
stream1 = Val(txtStreamBox.Text)
txtStreamBox.Text = ""
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles times.Click
multiply = True
stream2 = Val(txtStreamBox.Text)
txtStreamBox.Text = ""
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles divide.Click
division = True
index = index + 1
If index Mod 2 = 0 Then
stream1 = Val(txtStreamBox.Text)
txtStreamBox.Text = ""
Else
stream2 = Val(txtStreamBox.Text)
txtStreamBox.Text = ""
End If
End Sub
Private Sub compute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles compute.Click
If add = True Then
txtStreamBox.Text = stream1 + stream2
ElseIf subtract = True Then
txtStreamBox.Text = stream1 - stream2
ElseIf multiply = True Then
txtStreamBox.Text = stream1 * stream2
ElseIf division = True Then
txtStreamBox.Text = stream1 / stream2
ElseIf power = True Then
txtStreamBox.Text = Math.Pow(stream1, stream2)
End If
End Sub
End Class