<html>
<head>
<title>Calculator</title>
<script language="vb" Runat="server">
dim c as char
dim str as string
dim len as integer
dim Is2 as Boolean
dim num1 as double
dim num2 as double
dim result as double
'**************************************************
Sub btClick(Sender as Object , E as EventArgs)
If(Sender.Equals(btResult)) Then
Len = LoadStr.Text.Length()
If(Len = 0) Then Exit Sub
Len = LoadStr.Text.Length()
c = Right(LoadStr.Text,1)
str = Left(LoadStr.Text,Len-1)
num1 = Val(str)
num2 = Val(tbExps.Text)
result = num2
Select Case Asc(c)
Case 43
result = num1 + num2
Case 45
result = num1 - num2
Case 42
result = num1 * num2
Case 47
If(num2 = 0) Then
tbExps.Text = "除数不可以为零"
Exit Sub
End If
result = num1/num2
End Select
str = CStr(result)
Ltrim(str)
tbExps.Text = str
LoadStr.Text = ""
End If
'**************************************************
If(Sender.Equals(btAdd)) Then
LoadStr.Text = tbExps.Text + "+"
tbExps.Text = ""
End If
'**************************************************
If(Sender.Equals(btMin)) Then
LoadStr.Text = tbExps.Text + "-"
tbExps.Text = ""
End If
'**************************************************
If(Sender.Equals(btMul)) Then
LoadStr.Text = tbExps.Text + "*"
tbExps.Text = ""
End If
'**************************************************
If(Sender.Equals(btDiv)) Then
LoadStr.Text = tbExps.Text + "/"
tbExps.Text =""
End If
'**************************************************
If(Sender.Equals(btCls)) Then
tbExps.Text = ""
End If
'**************************************************
If(Sender.Equals(btBack)) Then
If(tbExps.Text.Length() <> 0) Then
str = tbExps.Text
len = tbExps.Text.Length()
tbExps.Text = Left(str,len-1)
End If
End If
'**************************************************
If(Sender.Equals(bt)) Then
If(Left(tbExps.Text,1) = "-") Then
str = tbExps.Text
len = tbExps.Text.Length()
tbExps.Text = Right(str,len-1)
Else
str = "-"
str += tbExps.Text
tbExps.Text = str
End If
End If
'**************************************************
If(Sender.Equals(btDot)) Then
If(tbExps.Text.Length() <> 0) Then
If(tbExps.Text.Length() <10) Then
tbExps.Text += "."
End If
End If
End If
'**************************************************
If(Sender.Equals(bt1)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "1"
Else
tbExps.Text += "1"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt2)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "2"
Else
tbExps.Text += "2"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt3)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "3"
Else
tbExps.Text += "3"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt4)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "4"
Else
tbExps.Text += "4"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt5)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "5"
Else
tbExps.Text += "5"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt6)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "6"
Else
tbExps.Text += "6"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt7)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "7"
Else
tbExps.Text += "7"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt8)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "8"
Else
tbExps.Text += "8"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt9)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text = "0") Then
tbExps.Text = "9"
Else
tbExps.Text += "9"
End If
End If
End If
'**************************************************
If(Sender.Equals(bt0)) Then
If(tbExps.Text.Length() <10) Then
If(tbExps.Text <> "0") Then
tbExps.Text += "0"
End If
End If
End If
End Sub
'****************************************************
Sub Help(Sender as Object, E as EventArgs)
if(lbHelp.visible) Then
lbHelp.visible = False
Else
lbHelp.visible = True
End if
End Sub
</script>
</head>