Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Random Number
Author:
Acorns
E-mail:
Click to e-mail author
Submitted:
7/6/2013
Version:
VB 2010
Compatibility:
VB 2010, VB 2012
Category:
Mathematics
Views:
5718
Picks 6 unique random numbers from 49 and displays them in label array.
Declarations:
Dim Lottery(6) As Integer Dim Counter, Counter2 As Integer Dim myLabelArray(6) As Label
Code:
'place one button and six labels on a form. myLabelArray(0) = Label1 myLabelArray(1) = Label2 myLabelArray(2) = Label3 myLabelArray(3) = Label4 myLabelArray(4) = Label5 myLabelArray(5) = Label6 'pick number between 1-49 and display in label For Me.Counter = 0 To 5 Lottery(Counter) = Int(Rnd() * 49) + 1 myLabelArray(Counter).Text = Lottery(Counter) 'Redraw if duplicated For Me.Counter2 = Counter - 1 To 0 Step -1 If Lottery(Counter) = Lottery(Counter2) Then Lottery(Counter) = 0 Counter = Counter - 1 End If Next Counter2 Next Counter
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement