HOW TO SORT AN ARRAY OF DATA STRINGS USING VISUAL BASIC 2010 (VB 2010)
DESCRIPTION
This Visual Basic 2010 code is a simple source code example of sorting an Array
of Data or Strings using Visual
Basic 2010 (VB2010).
|
THE VISUAL BASIC VB 2010 SETUP
In Module1 add the following lines to declare the variables:
Public Sorted As Boolean
Public MyArray(1000) As String
Public MyCounter As Integer
Public Temp As String
|
THE FREE VISUAL BASIC 2010 VB 2010 SOURCE CODE
'You need to have the Array filled with data, you can do this any way you like
from your program
Copy and Paste this code wherever you need it:
'.....Free VB2010 Source Code from www.freevb2010code.com
'Sort the Array in Incrementing Order (smallest first)
'Note that this also works with Strings!
Sorted = False
MyCounter = 20 '.......the number of items in the Array to be sorted
Do While Not Sorted
Sorted = True
For W = 0 To (MyCounter - 2)
If MyArray(W) >
MyArray(W + 1) Then
Temp = MyArray(W + 1)
MyArray(W + 1) = MyArray(W)
MyArray(W) = Temp
Sorted = False
End If
Next W
Loop
|
|