hi ive got a homework in vb.net to create a calcualtor that performs addition and subtraction and display the result in the textbox. however it is a little complicated since we have to use mouse contaol events to do this task. when the user enter a number in the text box then he clicks add the textbox clears and the user enter the second number then he clicks on the result button and the result is displayed in the textbox.My main problem is that in the code for the result button how will it know whether its an addition and substraction? Please help me thought the code.i'm stuck and i have to return it in 24 hours.


Private Sub txtDisplay_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDisplay.KeyPress
'If IsNumeric(e.KeyChar) Then
' e.Handled = True
'Else
' MsgBox("Please enter only numeric values")
' Me.Focus()
'End If
End Sub
'Private Sub btnResult_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnResult.MouseClick
' Select Case e.Button
' Case Windows.Forms.MouseButtons.Left
' z = x + y
' Me.txtDisplay.Text = z
' Case Windows.Forms.MouseButtons.Right
' s = x - y
' Me.txtDisplay.Text = s
' End Select
'End Sub
Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResult.Click
x = Val(txtDisplay.Text)
z = x + y
Me.txtDisplay.Text = z
End Sub
End Class

This article has been dead for over six months. Start a new discussion instead.