<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 = "Division cannot be zero"
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
**************************************** **********
I