用ASP做个简易计算器怎么做?求代码

 我来答
dongkouyuanfen
2008-04-01 · TA获得超过128个赞
知道答主
回答量:69
采纳率:0%
帮助的人:102万
展开全部
<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 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
百度网友856c3dd
2008-03-31 · TA获得超过2222个赞
知道大有可为答主
回答量:3168
采纳率:0%
帮助的人:2522万
展开全部
<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
%>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友43b5357
2008-03-31
知道答主
回答量:3
采纳率:0%
帮助的人:0
展开全部
<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>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
无籁义晓瑶
2020-05-01 · TA获得超过3875个赞
知道大有可为答主
回答量:3065
采纳率:25%
帮助的人:429万
展开全部
<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>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式