
您好再吗 我用VB做了一个简单的计算器但是代码不知道哪错了 能不能帮我写下呢 我发图给你看
PrivateSubCommand1_Click(IndexAsInteger)IfForm1.Tag="s"ThenIfIndex=10ThenText1.Text="...
Private Sub Command1_Click(Index As Integer)
If Form1.Tag = "s" Then
If Index = 10 Then
Text1.Text = "0"
Else
Text1.Text = Command1(Index).Caption
End If
Form1.Tag = ""
Else
Text1.Text = Text1.Text & Command1(Index).Caption
End If
End Sub
Private Sub Command2_Click(Index As Integer)
Form1.Tag = "s"
If v Then
x = Val(Text1.Text)
v = Not v
Else
y = Val(Text1.Text)
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
If y <> 0 Then
Text1.Text = x / y
Else
MsgBox ("不能以0为除数")
Text1.Text = x
v = False
End If
Case 4
y = 0
v = False
End Select
x = Val(Text1.Text)
End If
s = Index
End Sub
Private Sub Text1_Change()
Dim v As Boolean
Dim s As Integer
Dim x As Double
Dim y As Double
End Sub
这样之后数字能正常输入,运算不了 我刚学很多不懂啊 展开
If Form1.Tag = "s" Then
If Index = 10 Then
Text1.Text = "0"
Else
Text1.Text = Command1(Index).Caption
End If
Form1.Tag = ""
Else
Text1.Text = Text1.Text & Command1(Index).Caption
End If
End Sub
Private Sub Command2_Click(Index As Integer)
Form1.Tag = "s"
If v Then
x = Val(Text1.Text)
v = Not v
Else
y = Val(Text1.Text)
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
If y <> 0 Then
Text1.Text = x / y
Else
MsgBox ("不能以0为除数")
Text1.Text = x
v = False
End If
Case 4
y = 0
v = False
End Select
x = Val(Text1.Text)
End If
s = Index
End Sub
Private Sub Text1_Change()
Dim v As Boolean
Dim s As Integer
Dim x As Double
Dim y As Double
End Sub
这样之后数字能正常输入,运算不了 我刚学很多不懂啊 展开
展开全部
代码也贴出来看看呢?其实界面设计挺好的。
————————————————————
恩 我看到你的代码了。
你这工程代码控件比较多,你的控件名位置也不太确定,因此我不好自己做。
你如果把工程发过来,也许还可以检查一下。
————————————————————
恩 我看到你的代码了。
你这工程代码控件比较多,你的控件名位置也不太确定,因此我不好自己做。
你如果把工程发过来,也许还可以检查一下。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询