看不到我的经典 ASP 代码有什么问题
Can't see what's wrong with my Classic ASP code
我似乎找不到代码中的错误。它旨在从 HTML 形式输出从用户处获取的变量的时间 table。我收到 500 编程错误。
<html>
<head>
<title>My Times Tables</title>
</head>
<body>
<h1>Times Table: </h1>
<%
isValid = True
mult = request.form("multiple")
if not IsNumeric(mult) then
isValid = False
response.write("Not a number. Please try again...")
end if
if mult > 12 And mult < 1 then
isValid = False
response.write("Out of range. Please try again...")
end if
if isValid
%>
<table style="width:75%">
<%
For i = 1 to 12
%>
<tr>
<td><%= i %></td>
<td><%= mult %></td>
<th><%= (i * mult) %></th>
</tr>
<%
Next
end if
%>
</body>
</html>
您在 If isValid
之后缺少 Then
应该是
If isValid Then
和一个合乎逻辑的问题
If mult > 12 And mult < 1 Then
永远不会计算为 True
,因为 mult
变量不能同时大于 12 和小于 1( 同时 )。
您应该改用 Or
运算符。
If mult > 12 Or mult < 1 Then
我似乎找不到代码中的错误。它旨在从 HTML 形式输出从用户处获取的变量的时间 table。我收到 500 编程错误。
<html>
<head>
<title>My Times Tables</title>
</head>
<body>
<h1>Times Table: </h1>
<%
isValid = True
mult = request.form("multiple")
if not IsNumeric(mult) then
isValid = False
response.write("Not a number. Please try again...")
end if
if mult > 12 And mult < 1 then
isValid = False
response.write("Out of range. Please try again...")
end if
if isValid
%>
<table style="width:75%">
<%
For i = 1 to 12
%>
<tr>
<td><%= i %></td>
<td><%= mult %></td>
<th><%= (i * mult) %></th>
</tr>
<%
Next
end if
%>
</body>
</html>
您在 If isValid
Then
应该是
If isValid Then
和一个合乎逻辑的问题
If mult > 12 And mult < 1 Then
永远不会计算为 True
,因为 mult
变量不能同时大于 12 和小于 1( 同时 )。
您应该改用 Or
运算符。
If mult > 12 Or mult < 1 Then