站内搜索
广告
刚学ASP.Net,学了个简单的计算器
作者:    来源:    点击:    日期:2007-7-6 0:55:25   


<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
'**************************************************
首页 上一页 [1] [2] [3] [4]  下一页 尾页 
刚学ASP.Net,学了个简单的计算器 评论