⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 计算器.htm

📁 VBSCRIPT的源码,相信很多html程序员都会用到,这些源码小小变动一下,可以用在很多地方,尤其在DHTML中!
💻 HTM
字号:
<html>

<head>
<title>简单的计算器程序</title>
<script LANGUAGE="VBScript">
<!--
    sum=0
    flag=false       '重新输入数字的标志
    pending=0
    sub numpressed(num) '向文本框输出键入的数字
      if flag then
        text1.value=cstr(num)
        flag=false
      elseif text1.value="0" then
        text1.value=cstr(num)
      else
         text1.value=text1.value+cstr(num)
       end if
      end sub
      
      sub operation(op)        '加减乘除运算
        textvalue=text1.value
        if flag and op=5 then
          
              
        else
          flag=true
          select case pending
          case 1 
            sum=sum+csng(textvalue)
          case 2  
            sum=sum-csng(textvalue)
          case 3 
            sum=sum*csng(textvalue)
          case 4 
            sum=sum/csng(textvalue)
          case else
            sum=csng(textvalue)
          end select
          text1.value=cstr(sum)
          pending=op
          
        end if
         
       end sub
         
       sub clearentry  '清除刚输入的数字
          text1.value="0"
          sum=0
          flag=ture
       end sub
       
       sub clearall     '清除所有的计算
         sum=0
         pending=0
         clearentry
       end sub   
             
    
-->
</script>
</head>

<body  bgColor=lemonchiffon>
<p>
 
<p>
 
<table border="1" width="93%" height="204" bgcolor="#008080" style="text-align: center">
  <tr>
    <td width="56%" height="37" colspan="3"> 
    <input type="text" name="text1" size="30"></td>
    <td width="24%" height="37"> 
    <input type="button" value="   +   " name="btnplus" onclick="operation(1)"></td>
  </tr>
  <tr>
    <td width="19%" height="40">
      <input type="button" value="   1   " name="btn1" onclick="numpressed(1)"></td>
    <td width="20%" height="40"> 
      <input type="button" value="   2   " name="btn2" onclick="numpressed(2)"></td>
    <td width="17%" height="40"> 
      <input type="button" value="   3   " name="btn3" onclick="numpressed(3)"></td>
    <td width="24%" height="40">
      <input type="button" value="   -   " name="btnminus" onclick="operation(2)">
      </td>
  </tr>
  <tr>
    <td width="19%" height="38"> 
      <input type="button" value="   4   " name="btn4" onclick="numpressed(4)"></td>
    <td width="20%" height="38">
      <input type="button" value="   5   " name="btn5" onclick="numpressed(5)"></td>
    <td width="17%" height="38">
      <input type="button" value="   6   " name="btn6" onclick="numpressed(6)"></td>
    <td width="24%" height="38">
      <input type="button" value="   *   " name="btnmultipy" onclick="operation(3)"></td>
  </tr>
  <tr>
    <td width="19%" height="30">
      <input type="button" value="   7   " name="btn7" onclick="numpressed(7)"></td>
    <td width="20%" height="30">
      <input type="button" value="   8   " name="btn8" onclick="numpressed(8)"></td>
    <td width="17%" height="30">
      <input type="button" value="   9   " name="btn9" onclick="numpressed(9)"></td>
    <td width="24%" height="30">
      <input type="button" value="   /   " name="btndivide" onclick="operation(4)"></td>
  </tr>
  <tr>
    <td width="19%" height="29">
      <input type="button" value="   0   " name="btnzero" onclick="numpressed(0)"></td>
    <td width="20%" height="29">
      <input type="button" value="   ac   " name="btnac" onclick="clearall"></td>
    <td width="17%" height="29">
      <input type="button" value="   c   " name="btnc" onclick="clearentry"></td>
    <td width="24%" height="29">
      <input type="button" value="   =   " name="btnequals" onclick="operation(5)"></td>
  </tr>
</table>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p align="center"><font size="5" face="华文新魏">简单的计算器程序</font></p>

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -