Code:'Please ignore the above posting by me 'as it is a useless piece of crap 'this works just fine.... Option Explicit 'sorry for the lack of comments 'at work and busy... ' Public Sub BubbleSortNumbers(iArray As Variant) Dim Loop1 As Long Dim Loop2 As Long Dim lTemp As Long For Loop1 = UBound(iArray) To LBound(iArray) Step -1 For Loop2 = LBound(iArray) + 1 To Loop1 If iArray(Loop2 - 1) > iArray(Loop2) Then lTemp = iArray(Loop2 - 1) iArray(Loop2 - 1) = iArray(Loop2) iArray(Loop2) = lTemp End If Next Loop2 Next Loop1 Label1.Caption = "" Dim myStr As String Label1.FontSize = "14" For Loop2 = 1 To 7 myStr = iArray(Loop2) 'If Left(myStr, 1) = "," Then Left(myStr, 1) = "" Label1.Caption = Label1.Caption & "," & myStr Next myStr = Label1.Caption Dim myLen myLen = Len(myStr) 'get rid of , on right side of string If Right(myStr, 1) = "," Then myStr = Left(myStr, myLen - 1) Dim myString As String Dim iCount As Integer myAt = False myString = myStr myLen = Len(myString) 'get rid of , on left side of string For iCount = 1 To myLen If Left(myString, 1) = "," Then myString = Right(myString, (myLen - iCount)) End If Next Label1.Caption = myString End Sub ' ''''''''''''''''''''''''''''' Private Sub Command1_Click() Dim sarray(1 To 7) 'range of numbers is 1 to 15 Dim iCheck7(1 To 15) Dim a As Integer Dim i As Integer Dim iTemp As Integer For a = 1 To 15 iCheck7(a) = a Next Randomize For a = 1 To 1 + Int(Rnd * 7) i = Int(Rnd * (16 - a)) + a iTemp = iCheck7(a) iCheck7(a) = iCheck7(i) iCheck7(i) = iTemp sarray(a) = iCheck7(a) Next Call BubbleSortNumbers(sarray) End Sub




Reply With Quote