真是不好意思啊,老师,好久没有上传博客了,因为好久都没学会了,今天就把以前的空缺补上了。
(一) Option Explicit
Private Sub Command1_Click()
Dim i As Integer
Dim a(10) As Integer
Dim sum As Integer
Randomize
For i = 1 To 10
a(i) = Int(Rnd * 1000) + 1
sum = sum + a(i)
Next i
Print sum
End Sub
(二) Private Sub Command1_Click()
Cls
Dim n As Integer, s As Integer
Dim a(10) As Integer
n = 1
While n <= 10
a(n) = Int(Rnd * 1000)
n = n + 1
Wend
n = 1
While n <= 10
Print a(n)
n = n + 1
Wend
s = 0
n = 1
While n <= 10
s = s + a(n)
n = n + 1
Wend
Print s
End Sub
(三) Dim sum As Integer
Dim i As Integer
Dim a As Integer
Private Sub Command1_Click()
sum = 0
For i = 1 To 10
Randomize
a = Int(1000 * Rnd)
sum = sum + a
MsgBox "10个随机数和为:" & sum
Next
End Sub
(四)Dim sum As Integer
Dim i As Integer
Dim a As Integer
Private Sub Command1_Click()
sum = 0
For i = 1 To 10
Randomize
a = Int(1000 * Rnd)
sum = sum + a
Next
MsgBox "10个随机数和为:" & sum
Do While i <= 10
Randomize
a = Int(1000 * Rnd)
sum = sum + a
MsgBox "10个随机数和为:" & sum
Loop
End Sub
(五) Dim sum As Integer
Dim i As Integer
Dim a As Integer
Private Sub Command1_Click()
sum = 0
For i = 1 To 10
Randomize
a = Int(1000 * Rnd)
sum = sum + a
Next
MsgBox "10个随机数和为:" & sum
i = 1
Do Until i > 10
Randomize
a = Int(1000 * Rnd)
sum = sum + a
i = i + 1
Loop
MsgBox "10个随机数和为:" & sum