I am trying to incorporate a user input box in a VB script. The input has to be a number, not a string, in order for the application to accept the data into the field from the user input. This is what I have:
-----------------------------------------------------------
Sub Main
' Generated by the Reflection Macro Recorder on 11-20-2003 15:43:26.18.
' Generated by Reflection for UNIX and Digital 7.00.
Dim strX as String
Dim intR as Integer
Const NEVER_TIME_OUT = 0
Dim LF As String
Dim CR As String
Dim ESC As String
LF = Chr$(rcLF)
CR = Chr$(rcCR)
ESC = Chr$(rcESC)
With Application
intR = 0
strX = InputBox("enter serial number","test"
If IsNumeric(strX) Then
intR = CLng(strX)
Else
Msgbox "Enter a serial number"
End If
End With
End Sub
-----------------------------------------------------------
And this is the error message I get when I run the script:
"Type mismatch - A variable or argument is not of the correct type. For example, a string value cannot be assigned to an integer variable. This error also occurs when using Variant variables in an expression, and the Variant cannot be converted into the correct type for the expression."
Any suggestions?
thanks,
Barb
-----------------------------------------------------------
Sub Main
' Generated by the Reflection Macro Recorder on 11-20-2003 15:43:26.18.
' Generated by Reflection for UNIX and Digital 7.00.
Dim strX as String
Dim intR as Integer
Const NEVER_TIME_OUT = 0
Dim LF As String
Dim CR As String
Dim ESC As String
LF = Chr$(rcLF)
CR = Chr$(rcCR)
ESC = Chr$(rcESC)
With Application
intR = 0
strX = InputBox("enter serial number","test"
If IsNumeric(strX) Then
intR = CLng(strX)
Else
Msgbox "Enter a serial number"
End If
End With
End Sub
-----------------------------------------------------------
And this is the error message I get when I run the script:
"Type mismatch - A variable or argument is not of the correct type. For example, a string value cannot be assigned to an integer variable. This error also occurs when using Variant variables in an expression, and the Variant cannot be converted into the correct type for the expression."
Any suggestions?
thanks,
Barb