0 Replies - 1217 Views - Last Post: 14 January 2011 - 09:41 PM Rate Topic: -----

#1 blueberry85  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 14-January 11

adding multiple values from a textbox

Posted 14 January 2011 - 09:41 PM

hi! i'm new in vb and i'm doing my first calculator. the one i did now can add only two values at a time. I'm using three textboxes, one to display the equation, another to display the answer, and the third to hold the values to be added. i'm planning to hide the third textbox after i'm done ;) i want to add multiple values simultaneously using textboxes like in a scientific calculator but it only adds the last two values that i enter and would disregard all the others. please help :) here's my code:

Dim una As Double
Dim two As Double
Dim sEqual As String

Private Sub AC_Click()
Text2.Text = Clear
Text1.Text = Clear
Text3.Text = Clear
End Sub

Private Sub equal_Click()
two = Val(Text3.Text)
Select Case (sEqual)
Case "+"
    Text1.Text = una + two
Case "-"
    Text1.Text = una - two
Case "*"
    Text1.Text = una * two
Case "/"
    Text1.Text = una / two
End Select

End Sub

Private Sub num_Click(Index As Integer)
Text2.Text = Text2.Text & num(Index).Caption
Text3.Text = Text3.Text & num(Index).Caption
End Sub

Private Sub op_Click(Index As Integer)
una = Val(Text3.Text)
Text2.Text = Text2.Text & op(Index).Caption
Text3.Text = Clear
sEqual = op(Index).Caption
End Sub




Is This A Good Question/Topic? 0
  • +

Page 1 of 1