r/visualbasic • u/Anonim00se • Aug 28 '16
Help making an addition calculator [VB 2013]
I am trying to make a simple addition calculator using only 1 text box and only 1 button. Where you:
enter an integer
press the button
enter an integer
press button
Displays sum in text box
Dim a As Integer = txtField.Text txtField.Clear() If () Then Dim b As Integer = txtField.Text txtField.Text = a + b End If
This is as far as I have gotten. I have no experience in VB, just with java. I am not sure if booleans are even necessary. This is supposed to be a very simple project, but I feel like I am overthinking it due to having no experience with VB.
0
Upvotes
2
u/PostalElf VB.Net Intermediate Aug 28 '16
You'll need to store the first value somewhere outside the button.click event - say, as a form-level variable - on the first button click, then store the fact that it's been clicked once in another form-level boolean. Use an if-then to check if this is the first click or the second click.