random number

Discussion in 'ASP General' started by dave, Aug 23, 2004.

  1. dave

    dave Guest

    Hello all,
    I have written one function to generate random number.
    but every time I execute the function it repeats same
    number many times even though I'm using Randomize.

    function myrandnum()
    upperbound = 32767
    lowerbound = -32768
    Randomize
    myrandnum = Int((upperbound - lowerbound + 1) *
    Rnd + lowerbound)
    end function

    its not as good as effective as

    set objTools=server.CreateObject("MSWC.Tools")
    objTools.Random()

    Any help would be appreciated...
    Rgds
    dave
    dave, Aug 23, 2004
    #1
    1. Advertising

  2. G'day, Dave...

    A wise man once said, "the generation of random numbers is too important
    to be left to chance."

    Replace the generic "Randomize" statement with;

    Randomize Timer

    - Bob.


    "dave" <> wrote in message
    news:3c6d01c488ca$0f191590$...
    > Hello all,
    > I have written one function to generate random number.
    > but every time I execute the function it repeats same
    > number many times even though I'm using Randomize.
    >
    > function myrandnum()
    > upperbound = 32767
    > lowerbound = -32768
    > Randomize
    > myrandnum = Int((upperbound - lowerbound + 1) *
    > Rnd + lowerbound)
    > end function
    >
    > its not as good as effective as
    >
    > set objTools=server.CreateObject("MSWC.Tools")
    > objTools.Random()
    >
    > Any help would be appreciated...
    > Rgds
    > dave
    >
    Bob Milutinovic, Aug 23, 2004
    #2
    1. Advertising

  3. dave

    Guest Guest

    Or, use the inbult NewId() function inside sql server which does this
    automatically.


    "Bob Milutinovic" <> wrote in message
    news:...
    > G'day, Dave...
    >
    > A wise man once said, "the generation of random numbers is too

    important
    > to be left to chance."
    >
    > Replace the generic "Randomize" statement with;
    >
    > Randomize Timer
    >
    > - Bob.
    >
    >
    > "dave" <> wrote in message
    > news:3c6d01c488ca$0f191590$...
    > > Hello all,
    > > I have written one function to generate random number.
    > > but every time I execute the function it repeats same
    > > number many times even though I'm using Randomize.
    > >
    > > function myrandnum()
    > > upperbound = 32767
    > > lowerbound = -32768
    > > Randomize
    > > myrandnum = Int((upperbound - lowerbound + 1) *
    > > Rnd + lowerbound)
    > > end function
    > >
    > > its not as good as effective as
    > >
    > > set objTools=server.CreateObject("MSWC.Tools")
    > > objTools.Random()
    > >
    > > Any help would be appreciated...
    > > Rgds
    > > dave
    > >

    >
    >
    Guest, Aug 23, 2004
    #3
  4. dave

    dave Guest

    Thanx Bob..It worked good

    >-----Original Message-----
    >G'day, Dave...
    >
    > A wise man once said, "the generation of random

    numbers is too important
    >to be left to chance."
    >
    > Replace the generic "Randomize" statement with;
    >
    > Randomize Timer
    >
    > - Bob.
    >
    >
    >"dave" <> wrote in

    message
    >news:3c6d01c488ca$0f191590$...
    >> Hello all,
    >> I have written one function to generate random number.
    >> but every time I execute the function it repeats same
    >> number many times even though I'm using Randomize.
    >>
    >> function myrandnum()
    >> upperbound = 32767
    >> lowerbound = -32768
    >> Randomize
    >> myrandnum = Int((upperbound - lowerbound + 1) *
    >> Rnd + lowerbound)
    >> end function
    >>
    >> its not as good as effective as
    >>
    >> set objTools=server.CreateObject("MSWC.Tools")
    >> objTools.Random()
    >>
    >> Any help would be appreciated...
    >> Rgds
    >> dave
    >>

    >
    >
    >.
    >
    dave, Aug 24, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    Random NOt random?

    Darren Clark, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    445
    mikeb
    Jun 24, 2004
  2. xeys_00
    Replies:
    12
    Views:
    847
    Jonathan Arnold
    Apr 11, 2005
  3. globalrev
    Replies:
    4
    Views:
    746
    Gabriel Genellina
    Apr 20, 2008
  4. Alex Untitled
    Replies:
    11
    Views:
    651
    Giampiero Zanchi
    Nov 16, 2009
  5. VK
    Replies:
    15
    Views:
    1,130
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page