Having Trouble Making A Calculator In Vb6


Recommended Posts

i am trying to make an equal sign but when i click it if i have say 9+1 it equals 2 or if i give it 7+0 it equals nothing. i have it coded to work with only the add button right now i dont want to go any father until this is fixed.

Dim operand1 As Integer, operand2 As Integer
Dim ans As Integer

Private Sub CMDadd_Click()
sign = "+"
operand1 = Val(LBLans.Caption)
LBLans.Caption = "" 'Clear for next number
LBLsign.Caption = "+"
End Sub

Private Sub CMDans_Click()
If LBLsign.Caption = "+" Then
operand1 = Val(LBLans.Caption)
operand2 = LBLans.Caption
ans = operand1 + operand2
LBLans.Caption = ans
End If
End Sub

i am just starting to program in VB, i thought this would work but i guess not what am i doing wrong and what do i have to change, thanks in advance.

Edited by Wargod18
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...