I've been trying to do a little project on Visual Basic 4 (I know, old version. But it needs to work with old computers so), and I have this code for a calculator. It's for the equals command:
Private Sub Command12_Click()
Dim sd As Integer
Dim operator As Integer
Dim result As Integer
Dim Val As String
If operator = 1 Then
result = Val(num) + Val(txtOutput.Text)
txtOutput.Text = result
ElseIf operator = 2 Then
result = Val(num) - Val(txtOutput.Text)
txtOutput.Text = result
ElseIf operator = 3 Then
result = Val(num) * Val(txtOutput.Text)
txtOutput.Text = result
ElseIf operator = 4 Then
result = Val(num) / Val(txtOutput.Text)
txtOutput.Text = result
ElseIf operator = 5 Then
result = Val(num) Mod Val(txtOutput.Text)
txtOutput.Text = result
ElseIf operator = 6 Then
result = Val(num) * Val(num)
txtOutput.Text = result
End If
End Sub
The problem is, once I run it, it shows this error:
.
I tried searching on the Internet, and the only solution I have found online is to "Close and reopen Visual Basic and hope it works", but it doesn't... Any suggestions?
Dim Val As String. Why?