Hey,
I have to build an addition calculator. in the application interface should have a label on top which displays the number you clicked then under the label a running total label and then under than there should be a keypad with numbers from 0-9 and a plus sign. my plus sign should react as an equal button. so if i click 3 then + and then click 4...to see 7 i must click the plus button again. so to add a number o the sum the addition button must be clicked

heres what i have so far but i think im way off...i got frustrated because i tried different possibilities but i dont think i have the right idea.. id really appreciate it if someone can help me out

Option Explicit
Dim intTotal

Private Sub Form_Load()
intTotal = 0
lblTotal.Caption = intTotal
End Sub

Private Sub lbl1_Click()
lblClicked = 1
End Sub

Private Sub lbl2_Click()
lblClicked = 2
End Sub

Private Sub lbl3_Click()
lblClicked = 3
End Sub


Private Sub lblPlus_Click()
intTotal = lblClicked + lblClicked
End Sub

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

Try also to use CODE tags. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.