wekurn
09-17-2002, 09:54 AM
This week I am studying input boxes. I have a form with a text box, a command button and a label for the sum to be displayed.
Here is the code:
Private Sub Command1_Click()
Dim first As Single
Dim last As Single
Dim result As Single
first = Text1.Text
last = InputBox("Insert a value", "Value insertion")
result = first + last
Label1.Caption = result
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
I can get the text box and input box to add the values, but if I enter nothing, or press "cancel", I get the "type mismatch" error.
Where am I going wrong here?
Are errors handled later in the code? Is that what is meant by "error handling"
Here is the code:
Private Sub Command1_Click()
Dim first As Single
Dim last As Single
Dim result As Single
first = Text1.Text
last = InputBox("Insert a value", "Value insertion")
result = first + last
Label1.Caption = result
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
I can get the text box and input box to add the values, but if I enter nothing, or press "cancel", I get the "type mismatch" error.
Where am I going wrong here?
Are errors handled later in the code? Is that what is meant by "error handling"