?
Solved

Random Number

Posted on 1998-08-21
2
Medium Priority
?
198 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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…
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…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 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