刚学ASP.Net,学了个简单的计算器
<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 + "*"