关于用VB写计算器

来源:百度知道 编辑:UC知道 时间:2024/05/10 15:05:33
我自己写的代码...为什么不好用呢~我是刚学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<

我想可能是变量的问题,你试试将那几个变量定义为全局变量,具体操作:工程--添加模块;
然后输入以下语句:
Public num1#, num2#,sum#,act%
你再试试看...

地胜原要