Calculating from inputboxes, with error message for letter input
I've been struggelig with an embarrassing and annoying little problem in
visual basic (I'm, as you probbably see, a beginner). The problem is the
error message system for when letters are entered instead of numbers. I
get "can't convert from integer to string.
Any help on this would be most appreciated.
Here is my code:
Dim number1, number2 As Integer
Dim sum As String
number1 = InputBox("first value:")
number2 = InputBox("second value:")
sum = number1 + number2
If IsNumeric(sum) Then
MsgBox("The sum of the numbers " & number1 & " and " & number2 & "
is: " & sum)
ElseIf Not IsNumeric(sum) Then
MsgBox("You may only type numbers into the fields!, trie again")
End If
In advance, thank you :)!
No comments:
Post a Comment