|
发表于 2006-3-17 21:27:48
|
显示全部楼层
还有一个简单的HTML嵌套VB脚本的计算器
<html>
<body>
<script language="vbscript">
on error resume next
dim expression
sub addv(cv)
cv=trim(cv)
if( (cv="+") or (cv="-") or (cv="*") or (cv="\")) then
document.f1.resu.value=""
if (right(expression,1)="" or right(expression,1)="+" or right(expression,1)="-" or right(expression,1)="*" or right(expression,1)="\" )then
msgbox("猪头!这样怎么计算啊?")
expression=""
exit sub
end if
end if
expression=expression&cv
document.f1.resu.value=expression
end sub
sub compute()
document.f1.resu.value=eval(expression)
expression=document.f1.resu.value
end sub
sub crt()
expression=""
document.f1.resu.value=""
end sub
</script>
<form name="f1">
<div align="center">
<table width="200" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="4" align="center">甲儿计算器</td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="text" name="resu">
</div></td>
</tr>
<tr>
<td><div align="center">
<input type="button" value=" 1 " name="v1" onClick="addv('1')">
</div></td>
<td><div align="center">
<input type="button" value=" 2 " name="v2" onClick="addv('2')">
</div></td>
<td><div align="center">
<input type="button" value=" 3 " name="v3" onClick="addv('3')">
</div></td>
<td><div align="center">
<input type="button" value=" + " name="plus" onClick="addv('+')">
</div></td>
</tr>
<tr>
<td><div align="center">
<input type="button" value=" 4 " name="v4" onClick="addv('4')">
</div></td>
<td><div align="center">
<input type="button" value=" 5 " name="v5" onClick="addv('5')">
</div></td>
<td><div align="center">
<input type="button" value=" 6 " name="v6" onClick="addv('6')">
</div></td>
<td><div align="center">
<input type="button" value=" - " name="minu" onClick="addv('-')">
</div></td>
</tr>
<tr>
<td><div align="center">
<input type="button" value=" 7 " name="v7" onClick="addv('7')">
</div></td>
<td><div align="center">
<input type="button" value=" 8 " name="v8" onClick="addv('8')">
</div></td>
<td><div align="center">
<input type="button" value=" 9 " name="v9" onClick="addv('9')">
</div></td>
<td><div align="center">
<input type="button" value=" * " name="mult" onClick="addv('*')">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="button" value=" = " name="eqal" onClick="compute()">
</div></td>
<td><input type="button" value=" CR " name="cr" onClick="crt()"></td>
<td><div align="center">
<input type="button" value=" \ " name="divi" onClick="addv('\')">
</div></td>
</tr>
</table>
</div>
</form>
</body>
</html> |
|