|
-
Jul 12th, 2007, 10:16 AM
#1
Thread Starter
New Member
Visual Basic Shell Sort
Hello, I apologize if I'm posting this in the wrong place, and if this topic has already been addressed. I'm very new at VB, and am having some problems with a very simple program. What I need to do is generate 1000 random numbers in a list box upon clicking a button, and sort them using the shell sort function. I know this is probably the simplest thing, but I'm stuck and need some help. Thanks.
-
Jul 13th, 2007, 09:53 AM
#2
Re: Visual Basic Shell Sort
Welcome to the forums.
What are you having problems with, the random numbers or the algorithm?
If it's the former:
vb Code:
Dim xRan(1000)
Dim N As Integer
Randomize 'This statement initializes the seed
For N = 1 To 1000
xRan(N - 1) = Rnd()
Next
As for the algorithm, you may want to take a look at this article from the Wikipedia,
http://en.wikipedia.org/wiki/Shell_sort
There's code in various programming languages -unfortunately not in VB- but maybe you can convert it.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jul 13th, 2007, 09:55 AM
#3
Re: Visual Basic Shell Sort
Actually there are loads of sites with VB code. For example,
http://vbnet.mvps.org/index.html?cod.../qscompare.htm
The last subroutine at the bottom is for Shell sort.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Jul 13th, 2007, 12:42 PM
#4
Re: Visual Basic Shell Sort
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|