I want to make a program that will sort the users inputed numbers in a desending order. On my form I have a listbox ,a texrbox and two cmdButtons.
The user enters a several numbers (anywhere from a value of 1 to a million or so) example: 2; 25; 1,794; 4,009,546 etc. They then click one of the cmdButtons and this number is added to the listbox and I am guessing to an array. Once the user has entered all the numbers they need sorted., they click the other cmdButton and the numbers in the listbox are sorted. I am not familiar with sorting(bubble, quick) or arrays (how to populate them in real time)so any code on how to accomplish this would be greatly appreciated. Also I guess I would need a third button to clear listbox and the array (ReDim?) so the user could enter a new set of numbers to be sorted from least to greatest.
Dim splt
splt = split(text1.text)
Dim num as integer
Dim i as integer
dim x as integer
for i = 0 to list1.listcount - 1
for x = i to list1.listcount - 1
if (val(list1.list(i)) > val(list1.list(x))) then
num = val(list1.list(i))
list1.list(i) = list1.list(x)
list1.list(x) = num
end if
next x
next i
To clear the listbox, just use list1.clear