| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 485 人关注过本帖
标题:请大家帮帮我,计算器问题,拜托大家了
只看楼主 加入收藏
oo123456
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-12-27
收藏
 问题点数:0 回复次数:1 
请大家帮帮我,计算器问题,拜托大家了

无法实现加减乘除的功能..........
代码如下
Option Explicit
Dim x As Single, y As Single
Dim sz As Integer
Private Sub Command1_Click()
Text1.Text = Text1.Text & "1"
End Sub

Private Sub Command10_Click()
Text1.Text = Text1.Text & "0"


End Sub

Private Sub Command11_Click()
x = CSng(Text1.Text)
sz = 1
Text1.Text = ""
End Sub

Private Sub Command12_Click()
x = CSng(Text1.Text)
sz = 2
Text1.Text = ""
End Sub

Private Sub Command13_Click()
x = CSng(Text1.Text)
sz = 3
Text1.Text = ""
End Sub

Private Sub Command14_Click()
x = CSng(Text1.Text)
sz = 4
Text1.Text = ""
End Sub

Public Sub Run()
On Error GoTo ex
y = CSng(Text1.Text)
Select Case sz
Case 1
Text1.Text = x + y
Case 2
Text1.Text = x - y
Case 3
Text1.Text = x * y
Case 4
Text1.Text = x / y
End Select
ex:
End Sub

Private Sub Command16_Click()
x = CSng(Text1.Text)
Text1.Text = Sqr(x)
End Sub

Private Sub Command17_Click()
Text1.Text = ""
End Sub

Private Sub Command2_Click()
Text1.Text = Text1.Text & "2"
End Sub

Private Sub Command3_Click()
Text1.Text = Text1.Text & "3"
End Sub

Private Sub Command4_Click()
Text1.Text = Text1.Text & "4"
End Sub

Private Sub Command5_Click()
Text1.Text = Text1.Text & "5"
End Sub

Private Sub Command6_Click()
Text1.Text = Text1.Text & "6"
End Sub

Private Sub Command7_Click()
Text1.Text = Text1.Text & "7"
End Sub

Private Sub Command8_Click()
Text1.Text = Text1.Text & "8"
End Sub

Private Sub Command9_Click()
Text1.Text = Text1.Text & "9"
End Sub

搜索更多相关主题的帖子: 计算器 
2005-12-28 22:28
mjf007
Rank: 1
等 级:新手上路
帖 子:43
专家分:0
注 册:2005-12-2
收藏
得分:0 

老兄
这个计算器也太复杂了吧!
给你一个简单的计算器代码吧
Private Sub Option1_Click(Index As Integer)
a = Val(Text1.Text): b = Val(Text2.Text)
If Option1(0) Then Text3.Text = Format(a + b, "0.0")
If Option1(1) Then Text3.Text = Format(a - b, "0.0")
If Option1(2) Then Text3.Text = Format(a * b, "0.0")
If Option1(3) Then
If b = 0 Then
MsgBox "除数不得为零!", , "警告"
Text2.Text = "": Text2.SetFocus
Exit Sub
End If

Text3.Text = Format(a / b, "0.0")
End If
End Sub
Private Sub Text1_Change()
For i = 0 To 3
Option1(i).Value = False
Next i

End Sub

Private Sub Text2_Change()
For i = 1 To 3
Option1(i).Value = False
Next i
End Sub

Private Sub Check1_Click()
If Check1.Value = 1 Then
Text3.FontItalic = True
Else
Text3.FontItalic = False
End If

End Sub

2005-12-30 13:15
快速回复:请大家帮帮我,计算器问题,拜托大家了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018639 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved