用ASP做个简易计算器怎么做?求代码
4个回答
展开全部
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Calculate</title>
<script language="VBSCRIPT">
Function Show(m)
If (Myform.Expression.Value = "" AND InStr(". + - * / ",m)) Then
Myform.Expression.Value = ""
ElseIf (InStr("+ - * / . ",Right(Myform.Expression.Value,1)) And InStr("+ - * / ",m)) Then
ElseIf (m = ".") Then
If (InStr("+ - * / . ",Right(Myform.Expression.Value,1))) Then
ElseIf ((InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"+")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"-")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"*")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"/"))) Then
Else
Myform.Expression.Value = Myform.Expression.Value + m
End If
Else
Myform.Expression.Value = Myform.Expression.Value + m
END If
End Function
Function Sqrt()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)^2
End If
End Function
Function Result()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)
End If
End Function
Function Clean()
Myform.Expression.Value = ""
End Function
</script>
<style type="text/css">
<!--
.style5 {font-size: 18px}
-->
</style>
</head>
<body bgcolor="#ffffee" text=#000000>
<form name="myform" method="post" action="">
<div align="center">
<table bgcolor="#C0e0ff" width="214" height="245" border="4">
<tr>
<th width="206" scope="col"><H2><font color="#0000A0"> 计算器 </font></H2></th>
</tr>
<tr>
<th height="36" scope="col"><table width="200" border="1">
<tr>
<td colspan="4"><div align="center">
<input name="expression" type="text" value="" size="28" maxlength="28" >
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" id="seven"
onClick="Show('7')" VALUE=" 7 ">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 8 "
onClick="Show('8')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 9 "
onClick="Show('9')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" / "
onClick="Show('/')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 4 "
onClick="Show('4')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 5 "
onClick="Show('5')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 6 "
onClick="Show('6')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" * "
onClick="Show('*')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 1 "
onClick="Show('1')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 2 "
onClick="Show('2')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 3 "
onClick="Show('3')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" - "
onClick="Show('-')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 0 "
onClick="Show('0')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" . "
onClick="Show('.')">
</div></td>
<td><div align="center">
<input type="button" value="sqr"
onClick="sqrt()">
</div></td>
<td><div align="center">
<input type="button" value=" + "
onClick="Show('+')">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" AC "
onClick="clean()">
</div></td>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" = "
onClick="result()">
</div></td>
</tr>
</table></th>
</tr>
</table>
</div>
</form>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Calculate</title>
<script language="VBSCRIPT">
Function Show(m)
If (Myform.Expression.Value = "" AND InStr(". + - * / ",m)) Then
Myform.Expression.Value = ""
ElseIf (InStr("+ - * / . ",Right(Myform.Expression.Value,1)) And InStr("+ - * / ",m)) Then
ElseIf (m = ".") Then
If (InStr("+ - * / . ",Right(Myform.Expression.Value,1))) Then
ElseIf ((InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"+")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"-")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"*")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"/"))) Then
Else
Myform.Expression.Value = Myform.Expression.Value + m
End If
Else
Myform.Expression.Value = Myform.Expression.Value + m
END If
End Function
Function Sqrt()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)^2
End If
End Function
Function Result()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)
End If
End Function
Function Clean()
Myform.Expression.Value = ""
End Function
</script>
<style type="text/css">
<!--
.style5 {font-size: 18px}
-->
</style>
</head>
<body bgcolor="#ffffee" text=#000000>
<form name="myform" method="post" action="">
<div align="center">
<table bgcolor="#C0e0ff" width="214" height="245" border="4">
<tr>
<th width="206" scope="col"><H2><font color="#0000A0"> 计算器 </font></H2></th>
</tr>
<tr>
<th height="36" scope="col"><table width="200" border="1">
<tr>
<td colspan="4"><div align="center">
<input name="expression" type="text" value="" size="28" maxlength="28" >
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" id="seven"
onClick="Show('7')" VALUE=" 7 ">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 8 "
onClick="Show('8')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 9 "
onClick="Show('9')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" / "
onClick="Show('/')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 4 "
onClick="Show('4')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 5 "
onClick="Show('5')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 6 "
onClick="Show('6')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" * "
onClick="Show('*')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 1 "
onClick="Show('1')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 2 "
onClick="Show('2')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 3 "
onClick="Show('3')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" - "
onClick="Show('-')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 0 "
onClick="Show('0')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" . "
onClick="Show('.')">
</div></td>
<td><div align="center">
<input type="button" value="sqr"
onClick="sqrt()">
</div></td>
<td><div align="center">
<input type="button" value=" + "
onClick="Show('+')">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" AC "
onClick="clean()">
</div></td>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" = "
onClick="result()">
</div></td>
</tr>
</table></th>
</tr>
</table>
</div>
</form>
</body>
</html>
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
展开全部
<form name="form1" method="get" action="">
<p>操作数1:
<input type="text" name="text1">
</p>
<p>操作数2:
<input type="text" name="text2">
</p>
<p>选择你要进行的操作:</p>
<p>
<input type="radio" name="suan" value="加">加
<input type="radio" name="suan" value="减">减
<input type="radio" name="suan" value="乘">乘
<input type="radio" name="suan" value="除">除
</p>
<p>
<input type="submit" name="Submit" value="提交">
<input type="submit" name="Submit2" value="清空">
</p>
</form>
<%
dim a,b
a=cdbl(request.QueryString("text1"))
b=cdbl(request.QueryString("text2"))
if request.QueryString("suan")="加" then
response.Write("你选择的操作是加法:" & "<br>")
response.Write(a & "+" & b & "=" & a+b)
else
if request.QueryString("suan")="减" then
response.Write("你选择的操作是减法:" & "<br>")
response.Write (a & "-" & b & "=" & a-b)
else
if request.QueryString("suan")="乘" then
response.Write("你选择的操作是乘法:" & "<br>")
response.Write(a & "*" & b & "=" & a*b)
else
if request.QueryString("suan")="除" then
response.Write("你选择的操作是除法:" & "<br>")
response.Write(a & "/" & b & "=" & a/b)
else
end if
end if
end if
end if
%>
<p>操作数1:
<input type="text" name="text1">
</p>
<p>操作数2:
<input type="text" name="text2">
</p>
<p>选择你要进行的操作:</p>
<p>
<input type="radio" name="suan" value="加">加
<input type="radio" name="suan" value="减">减
<input type="radio" name="suan" value="乘">乘
<input type="radio" name="suan" value="除">除
</p>
<p>
<input type="submit" name="Submit" value="提交">
<input type="submit" name="Submit2" value="清空">
</p>
</form>
<%
dim a,b
a=cdbl(request.QueryString("text1"))
b=cdbl(request.QueryString("text2"))
if request.QueryString("suan")="加" then
response.Write("你选择的操作是加法:" & "<br>")
response.Write(a & "+" & b & "=" & a+b)
else
if request.QueryString("suan")="减" then
response.Write("你选择的操作是减法:" & "<br>")
response.Write (a & "-" & b & "=" & a-b)
else
if request.QueryString("suan")="乘" then
response.Write("你选择的操作是乘法:" & "<br>")
response.Write(a & "*" & b & "=" & a*b)
else
if request.QueryString("suan")="除" then
response.Write("你选择的操作是除法:" & "<br>")
response.Write(a & "/" & b & "=" & a/b)
else
end if
end if
end if
end if
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<title>
计算器
</title>
<body>
<form action=calculator.asp method=post>
操作数1: <input type=text name=num1><br>
操作数2: <input type=text name=num2><br>
<p>
选择你要进行的操作<br>
<input type=radio name=operation value="加" checked>加<br>
<input type=radio name=operation value="减">减<br>
<input type=radio name=operation value="乘">乘<br>
<input type=radio name=operation value="除">除<br>
<input type=submit><input type=reset>
</form>
<hr>
<%
dim n1,n2,op
if request.form.count=0 then
response.end
end if
n1=request.form("num1")
n2=request.form("num2")
op=request.form("operation")
if op="加" then
response.write n1
response.write "+"
response.write n2
response.write "="
response.write clng(n1)+clng(n2)
elseif op="减" then
response.write n1
response.write "-"
response.write n2
response.write "="
response.write clng(n1)-clng(n2)
elseif op="乘" then
response.write n1
response.write "*"
response.write n2
response.write "="
response.write clng(n1)*clng(n2)
elseif op="除" then
response.write n1
response.write "/"
response.write n2
response.write "="
response.write clng(n1)/clng(n2)
end if
%>
</body>
</html>
<title>
计算器
</title>
<body>
<form action=calculator.asp method=post>
操作数1: <input type=text name=num1><br>
操作数2: <input type=text name=num2><br>
<p>
选择你要进行的操作<br>
<input type=radio name=operation value="加" checked>加<br>
<input type=radio name=operation value="减">减<br>
<input type=radio name=operation value="乘">乘<br>
<input type=radio name=operation value="除">除<br>
<input type=submit><input type=reset>
</form>
<hr>
<%
dim n1,n2,op
if request.form.count=0 then
response.end
end if
n1=request.form("num1")
n2=request.form("num2")
op=request.form("operation")
if op="加" then
response.write n1
response.write "+"
response.write n2
response.write "="
response.write clng(n1)+clng(n2)
elseif op="减" then
response.write n1
response.write "-"
response.write n2
response.write "="
response.write clng(n1)-clng(n2)
elseif op="乘" then
response.write n1
response.write "*"
response.write n2
response.write "="
response.write clng(n1)*clng(n2)
elseif op="除" then
response.write n1
response.write "/"
response.write n2
response.write "="
response.write clng(n1)/clng(n2)
end if
%>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<title>
计算器
</title>
<body>
<form
action=calculator.asp
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<%
dim
n1,n2,op
if
request.form.count=0
then
response.end
end
if
n1=request.form("num1")
n2=request.form("num2")
op=request.form("operation")
if
op="加"
then
response.write
n1
response.write
"+"
response.write
n2
response.write
"="
response.write
clng(n1)+clng(n2)
elseif
op="减"
then
response.write
n1
response.write
"-"
response.write
n2
response.write
"="
response.write
clng(n1)-clng(n2)
elseif
op="乘"
then
response.write
n1
response.write
"*"
response.write
n2
response.write
"="
response.write
clng(n1)*clng(n2)
elseif
op="除"
then
response.write
n1
response.write
"/"
response.write
n2
response.write
"="
response.write
clng(n1)/clng(n2)
end
if
%>
</body>
</html>
<title>
计算器
</title>
<body>
<form
action=calculator.asp
method=post>
操作数1:
<input
type=text
name=num1><br>
操作数2:
<input
type=text
name=num2><br>
<p>
选择你要进行的操作<br>
<input
type=radio
name=operation
value="加"
checked>加<br>
<input
type=radio
name=operation
value="减">减<br>
<input
type=radio
name=operation
value="乘">乘<br>
<input
type=radio
name=operation
value="除">除<br>
<input
type=submit><input
type=reset>
</form>
<hr>
<%
dim
n1,n2,op
if
request.form.count=0
then
response.end
end
if
n1=request.form("num1")
n2=request.form("num2")
op=request.form("operation")
if
op="加"
then
response.write
n1
response.write
"+"
response.write
n2
response.write
"="
response.write
clng(n1)+clng(n2)
elseif
op="减"
then
response.write
n1
response.write
"-"
response.write
n2
response.write
"="
response.write
clng(n1)-clng(n2)
elseif
op="乘"
then
response.write
n1
response.write
"*"
response.write
n2
response.write
"="
response.write
clng(n1)*clng(n2)
elseif
op="除"
then
response.write
n1
response.write
"/"
response.write
n2
response.write
"="
response.write
clng(n1)/clng(n2)
end
if
%>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询