| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 606 人关注过本帖
标题:[求助]关于用VB写计算器
取消只看楼主 加入收藏
jtws3000
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2006-11-3
收藏
 问题点数:0 回复次数:0 
[求助]关于用VB写计算器

Dim num1, num2 As Double
Dim sum As Double
Dim act As Integer

Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
If Text1.Text = "" Then
Text1.Text = "0"
End If
Text1.Text = Text1.Text + "0"
Case 1
If Text1.Text = "" Then
Text1.Text = "1"
End If
Text1.Text = Text1.Text + "1"
Case 2
If Text1.Text = "" Then
Text1.Text = "2"
End If
Text1.Text = Text1.Text + "2"
Case 3
If Text1.Text = "" Then
Text1.Text = "3"
End If
Text1.Text = Text1.Text + "3"
Case 4
If Text1.Text = "" Then
Text1.Text = "4"
End If
Text1.Text = Text1.Text + "4"
Case 5
If Text1.Text = "" Then
Text1.Text = "5"
End If
Text1.Text = Text1.Text + "5"
Case 0
If Text1.Text = "" Then
Text1.Text = "6"
End If
Text1.Text = Text1.Text + "6"
Case 7
If Text1.Text = "" Then
Text1.Text = "7"
End If
Text1.Text = Text1.Text + "7"
Case 8
If Text1.Text = "" Then
Text1.Text = "8"
End If
Text1.Text = Text1.Text + "8"
Case 9
If Text1.Text = "" Then
Text1.Text = "9"
End If
Text1.Text = Text1.Text + "9"
Case 10
If Text1.Text = "" Then
Text1.Text = "."
End If
Case 11
num1 = CDbl(Text1.Text)
Text1.Text = ""
act = 1
Case 12
num1 = CDbl(Text1.Text)
Text1.Text = ""
act = 2
Case 13
num1 = CDbl(Text1.Text)
Text1.Text = ""
act = 3
Case 14
num1 = CDbl(Text1.Text)
Text1.Text = ""
act = 4
Case 15
num1 = CDbl(Text1.Text)
Text1.Text = ""
act = 5
Case 16
num1 = 0
num2 = 0
sum = 0
Text1.Text = ""
Case 17
num2 = CDbl(Text1.Text)
Select Case act
Case 1
sum = num1 + num2
Case 2
sum = num1 - num2
Case 3
sum = num1 * num2
Case 4
sum = num1 / num2
End Select
Text1.Text = ""
Text1.Text = sum
Case 18
End
End Select
End Sub

Private Sub Form_Load()
num1 = 0
num2 = 0
sum = 0
End Sub

问题补充:
哪里不对啊..

搜索更多相关主题的帖子: 计算器 
2007-04-19 10:26
快速回复:[求助]关于用VB写计算器
数据加载中...
 
   



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

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