muy bien directo al grano. Estoy Haciendo una calculadora con solo un textbox y 2 labels. La cosa es q me funciona de lo mas bien, pero a la hora de restar, me aparece en negativo. Alguien me puede ayudar? el codigo es el siguiente
Dim archivo
Private Sub CommandSumar_Click()
archivo = TextBox1.Text
Label1.Caption = archivo
TextBox1.Text = ""
Label2.Caption = "+"
TextBox1.SetFocus
End Sub
Private Sub CommandRestar_Click()
archivo = TextBox1.Text
Label1.Caption = archivo
TextBox1.Text = ""
Label2.Caption = "-"
TextBox1.SetFocus
End Sub
Private Sub CommandMultiplicar_Click()
archivo = TextBox1.Text
Label1.Caption = archivo
TextBox1.Text = ""
Label2.Caption = "*"
TextBox1.SetFocus
End Sub
Private Sub CommandDividir_Click()
archivo = TextBox1.Text
Label1.Caption = archivo
TextBox1.Text = ""
Label2.Caption = "/"
TextBox1.SetFocus
End Sub
Private Sub CommandResultado_Click()
If Label2.Caption = "+" Then
TextBox1.Text = Val(TextBox1) + Val(Label1)
ElseIf Label2.Caption = "-" Then
TextBox1.Text = Val(TextBox1) - Val(Label1)
ElseIf Label2.Caption = "*" Then
TextBox1.Text = Val(TextBox1) * Val(Label1)
ElseIf Label2.Caption = "/" Then
TextBox1.Text = Val(TextBox1) / Val(Label1)
Else
MsgBox ("you are fucket up")
End If
End Sub
Private Sub TextBox1_Change()
TextBox1.ForeColor = vbGreen
End Sub
Private Sub UserForm_Click()
End Sub