WEB开发网
开发学院WEB开发ASP.NET 刚学ASP.Net,学了个简单的计算器 阅读

刚学ASP.Net,学了个简单的计算器

 2007-12-15 09:34:00 来源:WEB开发网   
核心提示:<html> <head> <title>Calculator</title> <script language="vb" Runat="server"> dim c as char dim str as st


<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 + "*"

Tags:ASP Net 简单

编辑录入:coldstar [复制链接] [打 印]
赞助商链接