K
Kevin Sprinkel
Pressing Cancel from Inputbox returns a zero-length
string. Either you've declared astring as a numeric, or
Access has typed it for you based on your first listed
case.
The solution is to assign InputBox to a String or Variant;
test first for Cancel, and then do what you want with the
value of the string. Since there are only 2 cases, > 0
and not, you can use If:
Dim astring As Variant
astring = InputBox("Enter amount for each
payment: ", "Calculate Number of Payments")
If astring = "" Then
' User pressed Cancel
Exit Sub
End If
' Convert astring to a number
astring = Val(astring)
If astring > 0 Then
' Do some code here...
Else 'Entered illegal or negative number
' Do other code
End If
HTH
Kevin Sprinkel
string. Either you've declared astring as a numeric, or
Access has typed it for you based on your first listed
case.
The solution is to assign InputBox to a String or Variant;
test first for Cancel, and then do what you want with the
value of the string. Since there are only 2 cases, > 0
and not, you can use If:
Dim astring As Variant
astring = InputBox("Enter amount for each
payment: ", "Calculate Number of Payments")
If astring = "" Then
' User pressed Cancel
Exit Sub
End If
' Convert astring to a number
astring = Val(astring)
If astring > 0 Then
' Do some code here...
Else 'Entered illegal or negative number
' Do other code
End If
HTH
Kevin Sprinkel