RE: Visual Basic 6 Sorting Arrays

That's a cruid implementation of ubble sort ... Like I said, it's the most
inefficient way to sort your array, but it should work.

Take care,
Sina 

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Steven Hicks
Sent: Tuesday, September 18, 2007 3:22 AM
To: Programmingblind@xxxxxxxxxxxxx
Subject: Visual Basic 6 Sorting Arrays

Hello friends,

I found this code on the internet for sorting an array, does it look
reasonable to everyone?


'This Code Developed by Chris Vann
'Just copy it into a separate module, then call it from 'anywhere in your
program as SortArray ArrayGoesHere Dim Temp as Variant, X as Integer

Code:
Public Function SortArray(ByRef TheArray As Variant) Sorted = False Do While
Not Sorted
    Sorted = True
For X = 0 To UBound(TheArray) - 1
    If TheArray(X) > TheArray(X + 1) Then
        Temp = TheArray(X + 1)
        TheArray(X + 1) = TheArray(X)
        TheArray(X) = Temp
        Sorted = False
    End If
Next X
Loop
End Function

I don't really understand the variant part of it in the brackets.

Secondly the publick function sortarray, does this mean that I can call this
function anywhere in my VB code?  So I could adapt this and have an on error
which would go to a publick function for all of my code?

Any help appreciated as always.

Steve.


---------------------------------------------------------------------
-
-
-
-
-
-
The information in this e-mail and any attachments is confidential and is
intended for the attention and use of the named addressee(s).  It must not
be disclosed to any other person  without our authority.  If you are not the
intended recipient, or a person responsible for delivering it to the
intended recipient or are aware that this e-mail has been sent to you in
error, you are not authorised to and must not disclose, copy, distribute, or
retain this message or any part of it.

We sweep all outgoing messages for the presence of computer viruses. 
However, we cannot accept any responsibility for any loss or damage to your
systems due to viruses or malicious code not detected.

The statements and opinions expressed in this message are those of the
author and do not necessarily reflect those of the organisations within the
Cornwall & Isles of Scilly Health Community.

This email may be disclosed under the Freedom of Information  Act 2000 or
the Environmental Information Regulations 2004.
---------------------------------------------------------------------
-
-
-
-
-
-
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: