vb 程序运行时,单击“产生成绩” 按钮,随机生成10个0-100的 整数存于数字score中,并显示在text1中,成绩之间用空格隔开。单击“及格成绩”按钮,找出数组score中大于等于60 分的成绩,并按下顺序显示在 Text2中,成绩之间用空格隔 开
时间: 2023-05-29 20:07:41 浏览: 174
Private Sub btnGenerate_Click()
Dim score(9) As Integer
Dim i As Integer
Randomize '初始化随机数种子
For i = 0 To 9
score(i) = Int(Rnd() * 101) '生成0-100的随机整数
Next i
Text1.Text = Join(score, " ") '用空格将数组元素连接为字符串
End Sub
Private Sub btnPass_Click()
Dim score() As String
Dim i As Integer
score = Split(Text1.Text, " ") '将字符串分割成数组
For i = 0 To UBound(score)
If score(i) >= 60 Then
Text2.Text = Text2.Text & score(i) & " " '将及格成绩连接为字符串
End If
Next i
End Sub
阅读全文