random number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dave

    random number

    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

    #2
    Re: random number

    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" <anonymous@disc ussions.microso ft.com> wrote in message
    news:3c6d01c488 ca$0f191590$a30 1280a@phx.gbl.. .[color=blue]
    > 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
    >[/color]


    Comment

    • Guest's Avatar

      #3
      Re: random number

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


      "Bob Milutinovic" <someone@somewh ere.on.the.inte r.net> wrote in message
      news:eaBYfTNiEH A.1656@TK2MSFTN GP09.phx.gbl...[color=blue]
      > G'day, Dave...
      >
      > A wise man once said, "the generation of random numbers is too[/color]
      important[color=blue]
      > to be left to chance."
      >
      > Replace the generic "Randomize" statement with;
      >
      > Randomize Timer
      >
      > - Bob.
      >
      >
      > "dave" <anonymous@disc ussions.microso ft.com> wrote in message
      > news:3c6d01c488 ca$0f191590$a30 1280a@phx.gbl.. .[color=green]
      > > 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
      > >[/color]
      >
      >[/color]


      Comment

      • dave

        #4
        Re: random number

        Thanx Bob..It worked good
        [color=blue]
        >-----Original Message-----
        >G'day, Dave...
        >
        > A wise man once said, "the generation of random[/color]
        numbers is too important[color=blue]
        >to be left to chance."
        >
        > Replace the generic "Randomize" statement with;
        >
        > Randomize Timer
        >
        > - Bob.
        >
        >
        >"dave" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        message[color=blue]
        >news:3c6d01c48 8ca$0f191590$a3 01280a@phx.gbl. ..[color=green]
        >> 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
        >>[/color]
        >
        >
        >.
        >[/color]

        Comment

        Working...