vb编程问题!
Private Sub command1_click()
Dim a As Integer
Text1 = ""
For I = 1 To 6
Loop1:
a = Int(Rnd * 36 + 1)
If InStr(1, Text1.Text, " " & a & " ") <> 0 Then GoTo Loop1
Text1.Text = " " & Text1.Text & a & " "
MsgBox a
Next
End Sub
现在...................
怎样把得出的红球从小到大排列呢??
答案:Private Sub command1_click()
Dim a As Integer
Dim StrTmp As String
Dim ArrTmp() As String
Text1 = ""
For i = 1 To 6
Loop1:
a = Int(Rnd * 36 + 1)
If InStr(1, StrTmp, " " & a & " ") <> 0 Then GoTo Loop1
StrTmp = StrTmp & a & " "
Next
ArrTmp = Split(Left(StrTmp, Len(StrTmp) - 1), " ", -1)
For i = 0 To 5
For j = i + 1 To 5
If ArrTmp(i) > ArrTmp(j) Then
a = ArrTmp(i): ArrTmp(i) = ArrTmp(j): ArrTmp(j) = a
End If
Next
MsgBox ArrTmp(i)
Text1.Text = Text1.Text & ArrTmp(i) & " "
NextEnd Sub
用冒泡吧
上一个:求一个vb编程
下一个:VB编程问题