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

Random numbers?

Ok, very basic, but, leave it to me to forget such a thing ...

I want to set a variable to be a random number between one and ten.

ie:

thisNumber = Random(1, 10) ' something like this.
0
fibdev
Asked:
fibdev
1 Solution
 
fibdevAuthor Commented:
won't I feel silly if that code is correct  :)
0
 
clockwatcherCommented:
randomize
int(rnd()*10) + 1
0
 
asaflahv1Commented:
Private Sub Command1_Click()
Dim myvalue As Double
Randomize
myvalue = Int(10 * Rnd)

'or you can use it without the "int" if you dont need it in rounded numbers...
'myvalue = Rnd*10
End Sub

hope i've helped.

bye bye.
0
 
hesCommented:
Try this and see if it works for you:
Dim NewNumber
Randomize
NewNumber = Int((10 * Rnd) + 1)
0
 
fibdevAuthor Commented:
Thanks ...
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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