用vb编写一个计算器程序,实现加减乘除,
要求:可以从输入数据两文本框输入数据,同时水平,垂直滚动条滑块移动到相应位置,也可以通过水平垂直滚动滑块的移动产生数据,同时数据显示在两文本框中,单击加减乘除按钮实现运算...
要求:可以从输入数据两文本框输入数据,同时水平,垂直滚动条滑块移动到相应位置,也可以通过水平垂直滚动滑块的移动产生数据,同时数据显示在两文本框中,单击加减乘除按钮实现运算
展开
展开全部
Dim v As Boolean
Dim s As Integer
Dim X As Double
Dim Y As Double
Private Sub Command1_Click(Index As Integer)
If Form1.Tag = "T" 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 = "T"
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 Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
控件自己添加吧,空间名要和代码名一致
Dim s As Integer
Dim X As Double
Dim Y As Double
Private Sub Command1_Click(Index As Integer)
If Form1.Tag = "T" 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 = "T"
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 Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
控件自己添加吧,空间名要和代码名一致
--
2022-12-05 广告
2022-12-05 广告
public clas Computer{ public int sum(int a,int b){ int sum = a + b; return sum; } public int minus(int a,int b){ int min...
点击进入详情页
本回答由--提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询