查看文章
 
VB中简易计算器的制作
2007-01-09 9:48

上机报告7—简易计算器

(1)       设置属性

(2)       设计代码,如下:

Private Sub Form_Load()

    Option1.Value = True        '默认为“+”运算

End Sub

Private Sub Command1_Click()    '“计算”按钮

    Dim a As Single, b As Single, t As Single, s As String

    a = Val(Text1.Text)

    b = Val(Text2.Text)

    Select Case True

       Case Option1.Value       ' + 运算

          s = "+"

          t = a + b

       Case Option2.Value       ' - 运算

          s = "-"

          t = a - b

       Case Option3.Value       ' * 运算

          s = "*"

          t = a * b

       Case Option4.Value       ' / 运算

          s = "/"

          t = a / b

    End Select

    Text3.Text = a & s & b & "=" & t

End Sub

Private Sub Command2_Click()

    Text1.Text = ""

    Text2.Text = ""

    Text3.Text = ""

End Sub

 

Private Sub Command3_Click()

    end

End Sub

类别:计算机知识||添加到搜藏 |分享到i贴吧|浏览(1182)|评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
     

   
帮助中心 | 空间客服 | 投诉中心 | 空间协议
©2012 Baidu