网络编程
位置:首页>> 网络编程>> Asp编程>> 用VBS语言实现的网页计算器源代码

用VBS语言实现的网页计算器源代码

 来源:asp之家 发布时间:2007-12-26 17:09:00 

标签:计算器,VBS

用VBS语言实现的一个简单网页计算器,功能:可以进行加法、减法、乘法、除法、取反、开根号、及指数运算。虽然简单但是比起windows xp自带的计算器功能还是更强的。

截图如下:

程序作者:李笑天 来自:http://bbs.blueidea.com/thread-2802869-1-1.html

vbs代码如下:


<script language=vbscript>
dim num1,op
sub Number(num)
 if TxtValue.value="0" then
  if num="." then
   if instr(TxtValue.value,".") then
   else
    TxtValue.value=TxtValue.value & num
   end if
  else
   TxtValue.value=num
  end if
 else
  if num="." then
   if instr(TxtValue.value,".") then
   else
    TxtValue.value=TxtValue.value & num
   end if
  else
   TxtValue.value=TxtValue.value & num
  end if
 end if
end sub
sub opType(opT)
 num1=cDBL(TxtValue.value)
 op=opT
 TxtValue.value=""
end sub
sub equ()
 select case op
  case "+"
  txtvalue.value=cDBL(TxtValue.value) + num1
  case "-"
  txtvalue.value=cstr(num1 - cDBL(TxtValue.value) )
  case "*"
  txtvalue.value=cDBL(TxtValue.value) * num1
  case "/"
  txtvalue.value=cstr(num1 / cDBL(TxtValue.value) )
  case "z"
  TxtValue.value=cstr(num1 ^ cDbl(TxtValue.value))
 end select
 if left(txtvalue.value,1)="." then txtvalue.value= "0" & txtvalue.value
 num1=cDBL(TxtValue.value)
end sub
sub QL()
 num1=0
 TxtValue.value="0"
end sub
sub QF()
 TxtValue.value= cstr(-cDbl(TxtValue.value))
end sub
sub GH()
 TxtValue.value= sqr(cDbl(TxtValue.value))
end sub
</script>


网页计算器演示


0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com