Visual Basic 6 Sorting Arrays

  • From: "Steven Hicks" <Steven.Hicks@xxxxxxxxxxxxxxx>
  • To: <Programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 18 Sep 2007 08:21:33 +0100

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
//www.freelists.org/list/programmingblind

Other related posts: