Solved

Random Number

Posted on 1998-08-21
2
189 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

760 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

16 Experts available now in Live!

Get 1:1 Help Now