Vb题,在线等

Vb题,在线等在窗体中单击生成随机数按钮,生成100个之间的随机整数,并存入a数组中,同时显示在label1 中,单击排序按钮,对数组进行排序。并将结果显示在text 1中,单击退出按钮,结束程序的执行。
要求:1界面设「描述各控件的属性设置即可,用表格形式」2编写代码

第1个回答  2017-05-21

Dim a(100) As Integer


Private Sub Command1_Click()

Randomize

For i = 1 To 100

a(i) = Rnd * 100

Label1.Caption = Label1.Caption & a(i) & " "

If i Mod 10 = 0 Then

Label1.Caption = Label1.Caption & vbCrLf

End If

Next i

End Sub


Private Sub Command2_Click()

For i = 1 To 99

For j = 1 To 100 - i

If a(j) > a(j + 1) Then

t = a(j): a(j) = a(j + 1): a(j + 1) = t

End If

Next j

Next i

For i = 1 To 100

Text1.Text = Text1.Text & a(i) & " "

If i Mod 10 = 0 Then

Text1.Text = Text1.Text & vbCrLf

End If

Next i 

End Sub


Private Sub Command3_Click()

End

End Sub


Private Sub Form_Load()

Label1.Caption = ""

Text1.Text = ""

End Sub

本回答被提问者和网友采纳
相似回答