Bubble sort question 
Author Message
 Bubble sort question

Hi!
I made a bubbleSort like this:
Do
  Ready = True
 For J = 0 To List1.ListCount - 1
   If List1.List(J - 1) > List1.List(J) Then
      Temp = List1.List(J - 1)
      List1.List(J - 1) = List1.List(J)
      List1.List(J) = Temp
      Valmis = False
    End If
  Next J
Loop Until Ready = True

How can I replace the listbox vwith a Variable?
 something like:
Dim XXX(20)

 For J = 0 To List1.ListCount - 1
   If XXX(J - 1) > XXX(J) Then
      Temp = XXX(J - 1)
      XXX(J - 1) = XXX(J)
      XXX = Temp
      Valmis = False
    End If
  Next J

This does not work.
Thak you!



Fri, 12 Oct 2001 03:00:00 GMT  
 Bubble sort question
1.
for j = 0 to xxx....
x(j-1) does not exist - runtime error
2. redim xxx(list.listcount)
3. If you sort xxx you need to sort list to?

Do
  Ready = True
 For J = 0 To List1.ListCount - 1
   If List1.List(J - 1) > List1.List(J) Then
      Temp = List1.List(J - 1)
      List1.List(J - 1) = List1.List(J)
      List1.List(J) = Temp
      ready = False
    End If
  Next J
Loop Until Ready = True

Quote:

> Hi!
> I made a bubbleSort like this:
> Do
>   Ready = True
>  For J = 0 To List1.ListCount - 1
>    If List1.List(J - 1) > List1.List(J) Then
>       Temp = List1.List(J - 1)
>       List1.List(J - 1) = List1.List(J)
>       List1.List(J) = Temp
>       Valmis = False
>     End If
>   Next J
> Loop Until Ready = True

> How can I replace the listbox vwith a Variable?
>  something like:
> Dim XXX(20)

>  For J = 0 To List1.ListCount - 1
>    If XXX(J - 1) > XXX(J) Then
>       Temp = XXX(J - 1)
>       XXX(J - 1) = XXX(J)
>       XXX = Temp
>       Valmis = False
>     End If
>   Next J

> This does not work.
> Thak you!

--



Fri, 12 Oct 2001 03:00:00 GMT  
 Bubble sort question

Quote:

>Hi!
>I made a bubbleSort like this:
>Do
>  Ready = True
> For J = 0 To List1.ListCount - 1

With J=0, the first iteration attempts to compare List1.List(-1) to
List1.List(0). This loop should start with J=1 since List1.List(-1) is
undefined.

Quote:
>   If List1.List(J - 1) > List1.List(J) Then
>      Temp = List1.List(J - 1)
>      List1.List(J - 1) = List1.List(J)
>      List1.List(J) = Temp
>      Valmis = False

I believe the above s/b 'Ready = False'.

Quote:
>    End If
>  Next J
>Loop Until Ready = True

>How can I replace the listbox vwith a Variable?
> something like:
>Dim XXX(20)

> For J = 0 To List1.ListCount - 1
>   If XXX(J - 1) > XXX(J) Then
>      Temp = XXX(J - 1)
>      XXX(J - 1) = XXX(J)
>      XXX = Temp
>      Valmis = False
>    End If
>  Next J

>This does not work.
>Thak you!

Since there are two known reasons why this doesn't work, I'm not surprised
it didn't, but why do you want to replace listbox with a variable?  To save
yourself some typing? It wouldn't save much.  You might want to look into
the 'cutting' and 'pasting' or 'copying' functions available in the editor.

-CB



Fri, 12 Oct 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Date Comparison in a Bubble Sort

2. Bubble Sort

3. Bubble Sort Code

4. Bubble sort program code

5. Problem with bubble sort

6. Bubble Sort

7. need help with bubble sort

8. Animated Bubble Sort ??

9. Bubble Sort Poblem

10. Bubble Sort Poblem

11. Bubble sort program code

12. Need Bubble Sort DLL/VBX

 

 
Powered by phpBB® Forum Software