vb数组 编程语句··

来源:百度知道 编辑:UC知道 时间:2024/07/04 09:18:23
单击第一个按钮,生成20个[0,100]之间的随机整数,显示于文本框中,单击第二个按钮,求这20个随机整数中的最大数,并将其显示在另一个文本框中。

Dim a(20) As Integer, Max As Integer
Private Sub Command1_Click()
Text1.Text = ""
For i = 1 To 20
a(i) = Int(Rnd * 101)
Text1.Text = Text1.Text & a(i) & " "
If i Mod 10 = 0 Then Text1.Text = Text1.Text & vbCrLf
If Max < a(i) Then Max = a(i)
Next i
End Sub

Private Sub Command2_Click()
Text2.Text = ""
Text2.Text = Max
End Sub

Dim a(20) As Integer, I As Integer

Private Sub command1_click()
Dim st As String
For I = 1 To 20
a(I) = Int(Rnd * 101)
st = st + Str(a(I))
Next
Text1.Text = st
End Sub

Private Sub Command2_Click()
a(0) = a(1)
For I = 2 To 19
If a(0) < a(I) Then a(0) = a(I)
Next
Text2.Text = Str(a(0))
End Sub
已经运行过.

Dim a(20) As Integer'定义一个20个大小的数组
Private Sub Command1_Click()

For i = 1 To 20