Results 1 to 4 of 4

Thread: Random coding

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    4

    Random coding

    is there any oyher way in VB to generate a random number other than

    Code:
    dim intNum as integer
    
    IntNum = (rnd*10)
    this seems to give a less than random sequence even when compiled and I want to build a random generator into my RPG software

    many thanks in advance

  2. #2
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Random coding

    If you put the Randomize it makes your number truly random. If you don't it follows a set sequence.

    Code:
    dim intNum as integer
    
    randomize
    IntNum = (rnd*10)
    Edit: Randomize only needs to be called once so put it in your form load. You don't want to call it more than once.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    4

    Re: Random coding

    many thanks very helpfull but I have one question

    do you need to call that in the module where the sub routines are or will the form load call do that as well? and does it need to be called in each form used?

  4. #4
    Fanatic Member Mxjerrett's Avatar
    Join Date
    Apr 2006
    Location
    Oklahoma
    Posts
    939

    Re: Random coding

    It only needs to be called once per program execution.

    If a post has been helpful please rate it.
    If your question has been answered, pull down the tread tools and mark it as resolved.

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