Solved

Random Number

Posted on 1998-08-21
2
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

691 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