Results 1 to 2 of 2

Thread: [RESOLVED] Generating Random Numbers in VB6

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Resolved [RESOLVED] Generating Random Numbers in VB6

    For a project I have currently done, I have designed a database that contains a table, which contains the field "NHS Number". People in the UK would know that this is a unique ten digit number.

    I am in the process of adding "people" into the database for testing purposes.

    In real life, different people would have totally different NHS Numbers, so using AutoNumber is totally out of the question. So I have to have a random number...

    I have currently made a random integer generator to solve this problem... or so I thought

    Using the following code:
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim dblRand As Double
    3.     Dim strRand As String
    4.     dblRand = Int(Rnd * 10000000000#)
    5.     Text1.Text = dblRand
    6.     Clipboard.Clear
    7.     strRand = dblRand
    8.     Clipboard.SetText strRand
    9. End Sub

    Using the
    Code:
    Int()
    command doesn't acutally generate a random number each time for me. While I'm running the program, it generates random numbers, fair enough. When I start the program again, it generates the same random numbers it did before

    Is there something I've done wrong? Is there another way to randomise numbers?

    Thanks

  2. #2

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: [RESOLVED] Generating Random Numbers in VB6

    Done a VBF search: Answer

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