Discussion in 'Web Design & Coding' started by Liger ZERO, Apr 3, 2003.
Is there a built in function in Visual Basic that will alphabetize an array of variables?
This seems to be a bit of a misnomer to me. Arrays are treated as a single variable in VB; the only difference is that it’s indexed internally. If you wish to input the entire alphabet into an array in the correct order so as to produce the expected result of a =1 b=2 (or the reverse) you would have to sort all the letters prior to pushing them into the array. This is kind of like doing the same equation twice and is best avoided, however this does have its place where huge amounts of comparisons need to be done quickly with little output translation or to push straight into another function. This is a complex subject and one reason why I mostly design my own arrays that can accept any data type as apposed to visual basics single data type.
Try this link:
On the right click Sorting, then click quicksort. This is a mod that I used and it does a good job sorting thousands of records very quickly
These should have made illegal years ago. Whilst there may be the occasional use that might have been justified ten years ago I can’t see any use for them in a modern computer language as is you have to “strap-up” one set of variables and then compare the with another, your programme is badly designed or even not thought through.
Don’t use them. END.
Unfortunately everyone here is right, there isn't a built in function to sort alphabetically in Visual Basic. However, a sub routine can easily be built to do it. There are a few different ways of doing it, one of the most popular is known as a 'Bubble Sort'
Just use this code (I made it in a couple minutes so its not perfect)
At the bottom where it says 'testing(i)' just change the 'testing' to the name of the array you are sorting.
Then an example of its use would be:
Hope this helps.