Hi,
This is a very simple example. I'm just beginning to learn VBScript. I keep getting an error message "Expected 'End" or "Expected 'Then" when running this code. It is out of a book and I copied it exactly. It's driving me crazy. Someone please help!!!
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
Function ValidInteger(sNumber,iMin,iMax)
If IsNumeric(sNumber) = 0 Then
If InStr(sNumber,"." Then
If CLng(sNumber)>= iMin And CLng(sNumber)<= iMax Then ValidInteger=""
Else
ValidInteger = "You must enter a number between " & iMin & " and " & iMax
End If
Else
ValidInteger = "You must enter a whole number"
End If
Else
ValidInteger = "You must enter a number value"
End If
End Function
Sub cmdCheckForm_onClick
Dim sValidity
sValidity = ValidInteger(form1.text1.value,1,10)
If sValidity = " " Then
MsgBox "Valid!!!"
Else
MsgBox sValidity
End If
End Sub
</SCRIPT>
<FORM action="" method=POST id=form1 name=form1>
<INPUT id=text1 name=text1>
<INPUT type="button" value="button" id=cmdCheckForm name=cmdCheckForm>
</FORM>
</BODY>
</HTML>
This is a very simple example. I'm just beginning to learn VBScript. I keep getting an error message "Expected 'End" or "Expected 'Then" when running this code. It is out of a book and I copied it exactly. It's driving me crazy. Someone please help!!!
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
Function ValidInteger(sNumber,iMin,iMax)
If IsNumeric(sNumber) = 0 Then
If InStr(sNumber,"." Then
If CLng(sNumber)>= iMin And CLng(sNumber)<= iMax Then ValidInteger=""
Else
ValidInteger = "You must enter a number between " & iMin & " and " & iMax
End If
Else
ValidInteger = "You must enter a whole number"
End If
Else
ValidInteger = "You must enter a number value"
End If
End Function
Sub cmdCheckForm_onClick
Dim sValidity
sValidity = ValidInteger(form1.text1.value,1,10)
If sValidity = " " Then
MsgBox "Valid!!!"
Else
MsgBox sValidity
End If
End Sub
</SCRIPT>
<FORM action="" method=POST id=form1 name=form1>
<INPUT id=text1 name=text1>
<INPUT type="button" value="button" id=cmdCheckForm name=cmdCheckForm>
</FORM>
</BODY>
</HTML>