Results 1 to 4 of 4

Thread: Visual Basic Shell Sort

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Location
    MS
    Posts
    1

    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.

  2. #2
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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:
    1. Dim xRan(1000)
    2. Dim N As Integer
    3. Randomize 'This statement initializes the seed
    4.  
    5. For N = 1 To 1000
    6.    xRan(N - 1) = Rnd()
    7. 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)

  3. #3
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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)

  4. #4
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    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
  •  



Click Here to Expand Forum to Full Width