新建一个命令按钮Command1,添加以下代码:
Private
Sub
Command1_Click()
Dim
i
As
Integer
For
i
=
1
To
100
If
(i
Mod
5
=
0)
And
(i
Mod
3
<>
0)
Then
Text1.Text
=
Text1.Text
&
vbCrLf
&
i
Next
End
Sub
楼主您好!
代码如下:
Option ExplicitPrivate 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 Form_Click()Dim a, b, c, d As StringDim sum, aver As Longa = Val(InputBox("请输入第一个数"))b = InputBox("请输入第二个数")
c = InputBox("请输入第三个数")
d = InputBox("请输入第四个数")
sum = a + b + c + d
aver = sum / 4
Print "所输入的4个数字分别是"a, b, c, d
Print "4个数字的和为"sum
Print "4个数字的平均值为"averEnd Sub VB6.0下调试通过。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)