用vb编写一个小程序
有8个文本框,两个command按钮一个是计算一个是清除前7个文本框用来输入数值然后点击计算在第8个文本框显示前七个数的和或者差或者乘积,点击清除按钮清空文本框中输入的数...
有8个文本框,两个command 按钮 一个是计算 一个是清除 前7个文本框用来输入数值 然后点击计算 在第8个文本框显示前七个数的和或者差或者乘积,点击清除按钮 清空文本框中输入的数
展开
2个回答
展开全部
楼主您好!
代码如下:
Option Explicit
Private Sub Command1_Click()
Dim n(7) As Double
Dim k(3) As Double
k(3) = 1
Dim j As Integer
For j = 1 To 7
n(j) = Val(Controls("Text" & CStr(j)).Text)
Next j
For j = 1 To 7
k(1) = k(1) + n(j)
k(2) = k(2) - n(j)
k(3) = k(3) * n(j)
Next j
Me.Text8.Text = "7个数的和为:" & k(1) & vbCrLf & _
"7个数的差为:" & k(2) & vbCrLf & _
"7个数的乘积为:" & k(3)
End Sub
Private Sub Command2_Click()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i)).Text = ""
Next i
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 8
Controls("Text" & CStr(i)).Text = ""
Next i
End Sub
展开全部
Private Sub Command1_Click()
Text8 = Str(Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4) + Val(Text5) + Val(Text6) + Val(Text7))
End Sub
Private Sub Command2_Click()
Text1 = "": Text2 = "": Text3 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = "": Text8 = "":
End Sub
Private Sub Form_Load()
Command1.Caption = "计算"
Command2.Caption = "清空"
Text1 = "": Text2 = "": Text3 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = "": Text8 = "":
End Sub
Text8 = Str(Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4) + Val(Text5) + Val(Text6) + Val(Text7))
End Sub
Private Sub Command2_Click()
Text1 = "": Text2 = "": Text3 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = "": Text8 = "":
End Sub
Private Sub Form_Load()
Command1.Caption = "计算"
Command2.Caption = "清空"
Text1 = "": Text2 = "": Text3 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = "": Text8 = "":
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询