Free Visual Basic 2010 Source Code VB2010
How to Sort an Array of Data or Strings








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




Home to freevb2010code.com
VB2010 How to write to a CSV file
VB2010 How to write to a TEXT file
VB2010 How to read from a CSV file
VB2010 How to read from a TEXT file
VB2010 How to find a User Name
VB2010 How to fill a ListView
VB2010 How to write a ListView data table to a CSV file
VB2010 How to call another program
VB2010 How to copy and paste to the Windows Clipboard
VB2010 How to sort an array
VB2010 How to concatenate / join strings / text


Copyright SGDesigns (c)2010

Our aim is to provide simple concise and easy to follow Free Visual Basic 2010 Source Code for the casual programmer in VB2010. We hope you find the VB2010 code example uselful. This VB 2010 code shows a simple method of how to sort an Array using Visual Basic 2010.





counter