• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

find a random number in a range ( between 2 numbers)


I need use VB to generate a random number between 2 numbers. for example:

generate a random number between 103 and 205, the program return me 165. something like this.

0
rmtogether
Asked:
rmtogether
  • 2
  • 2
1 Solution
 
Harisha M GCommented:
Hi PeterdeB,

LowerNo + Rnd() * (UpperNo - LowerNo)

---
Harish
0
 
Harisha M GCommented:
rmtogether, you might also want to add Int or Round if you want it to be integer..

LowerNo + Int(Rnd() * (UpperNo - LowerNo))
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Randomize

Dim iYourNumber As Integer
iYourNumber = CInt((205 - 103) * Rnd) + 103
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
{too slow...}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now