the way calculators normally work is that
You type the first number
You hit +
You type the second number
You hit = (or plus again)
So you need some variables to remember
1. the first number that was typed,
2. the operator that was clicked
Your numbers should be buttons not labels with code like
private sub cmd1_click()
lblTotal.text = lblTotal.text & "1"
end sub
when the user click on the plus you have to remember this value and the function
private sub cmdPlus_Click
FirstNumber = lblTotal.text ' FirstNumber will need to be a module based variable
Operator = "+"
lblTotal.Text = ""
end if
the code for = will need to be something like
private sub cmdEqual_Click()
select Case Operator
case "+"
lblTotal.text = lblTotal.text + FirstNumber
case "-"
lblTotal.text = FirstNumber - lblTotal.text
end select
end if ChrisPadgham
Posting Pro in Training
413 posts since Sep 2009
Reputation Points: 102
Solved Threads: 78