Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 9th, 2006, 12:22 AM
Authorized User
 
Join Date: Aug 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with Rnd()

hello everybody ...
i'm facing a small prob using Rnd()
i want 2 generate 15 random integer numbers between the range of "0 to 99" and every number should be added in a list box, i've written the following code on the click event of a button

For A=1 to 15
List1.AddItem CInt(Rnd() * 99)
Next A

but the problem iz that, every time when i run the program and click on the button, it alwayz displays the same numbers, so how can V call them random numbers as they R being repeated evey time, iz there n.e 1 who can solve my problem

i'll w8 4 a good reply

 
Old April 9th, 2006, 12:29 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

use Randomize inside the For loop

 
Old April 10th, 2006, 09:37 AM
Authorized User
 
Join Date: Aug 2005
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey ... could u plz do a favour 4 me
plz give me a small piece of code (By Using Randomize) of the task that i've described above ... plz plz plz

i'll w8 4 a good reply

 
Old April 12th, 2006, 09:38 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

For A=1 to 15
  Randomize
  List1.AddItem CInt(Rnd() * 99)
Next A






Similar Threads
Thread Thread Starter Forum Replies Last Post
Rnd Function ghall202 Access VBA 2 April 17th, 2008 10:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.