Solved

Random Number

Posted on 1998-08-21
2
191 Views
Last Modified: 2010-04-30
I need to know how to get a random number in Visual Basics.  I know how to write the code in java but as yet haven't found a way to get  V.B jto generate a random number.  Any hints or help is appreciated
0
Comment
Question by:ARROWTHORNE
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1430229
First :

Randomize

Rnd(number) => it will return a number between

If number is      Rnd generates
Less than zero      The same number every time, using number as the seed.
Greater than zero      The next random number in the sequence.
Equal to zero      The most recently generated number.
Not supplied      The next random number in the sequence.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1430230
Hi, Here is a code to generate a random integer value from 1 to 6


Option Explicit

Private Sub Command1_Click()
'This example uses the Rnd function to generate a random integer value from 1 to 6.
Dim MyValue
Randomize   ' Initialize random-number generator.

MyValue = Int((6 * Rnd) + 1)    ' Generate random value between 1 and 6.
Label1.Caption = MyValue
End Sub


if you need more help email to: shay@hili.com
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now