谁能告诉我vb答案
单击第一个按钮,生成20个〔0,100〕之间的随机整数,显示于文本框中,单击第二个按钮,求这20个随机整数中的最大数,并将其显示在另一个文本框中.
参考答案:设置Text1的属性MultiLine为True
Option Explicit
Dim rnd_sj(20)
Dim i As Integer
Dim bj As Integer
Private Sub Command1_Click()
Text1 = ""
For i = 1 To 20
rnd_sj(i) = Int((101 * Rnd))
Text1 = Text1 & rnd_sj(i) & vbNewLine
Next
End Sub
Private Sub Command2_Click()
Dim a As Integer
a = rnd_sj(1)
For i = 2 To 20
If rnd_sj(i) > a Then
a = rnd_sj(i)
ElseIf rnd_sj(i) <= a Then
a = a
End If
Next
Text2 = a
End Sub
Private Sub Form_Load()
Randomize
End Sub