button + in calc works bad.
-
Hello all; I have a question for my calculator project. command13 is a + button. when you sum 2 number it works correctly. but if you press this button for second time it will sum the last result with itself & again & again if you press + button. NOW HELP ME : what should I do to avoid sum in 2nd,3rd,... button click? snippet code is appended. Private Sub Command13_Click() Combo1.AddItem Combo1.Text Combo1.AddItem "+" 'b = Combo1.ListCount Select Case o Case Is = 1 Combo1.Text = a + Val(Combo1.Text) Case Is = 2 Combo1.Text = a - Val(Combo1.Text) Case Is = 3 Combo1.Text = a * Val(Combo1.Text) Case Is = 4 Combo1.Text = a / Val(Combo1.Text) End Select a = Val(Combo1.Text) h = 1 o = 1 End Sub Thanks anyone help me...
-
Hello all; I have a question for my calculator project. command13 is a + button. when you sum 2 number it works correctly. but if you press this button for second time it will sum the last result with itself & again & again if you press + button. NOW HELP ME : what should I do to avoid sum in 2nd,3rd,... button click? snippet code is appended. Private Sub Command13_Click() Combo1.AddItem Combo1.Text Combo1.AddItem "+" 'b = Combo1.ListCount Select Case o Case Is = 1 Combo1.Text = a + Val(Combo1.Text) Case Is = 2 Combo1.Text = a - Val(Combo1.Text) Case Is = 3 Combo1.Text = a * Val(Combo1.Text) Case Is = 4 Combo1.Text = a / Val(Combo1.Text) End Select a = Val(Combo1.Text) h = 1 o = 1 End Sub Thanks anyone help me...
some calculators work that way; others don't want to perform a second operation until a new number has been entered. decide what functionality you want, then implement it. if necessary keep track of what happened most recently (enter number parts, i.e. digits, minus sign, period) or click operator. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).