hi, i have to play bingo in vb , but im really stuck....i just need very simple code to create random numbers in one label.....thank s for your help
bingo codes needed
Collapse
X
-
Couldn't resist to quickly put somethig together, but I would assume there are much more sophisticated program around. At least you have a starting point here.
Add a command1, command2 button and a text1 field to your form, and paste the code below in yor program code and bingo! :-))
I would extend the program to show on screen all numbers drawn sofar, etc...
[CODE=vb]Option Explicit
Const MAX As Integer = 80'set max nr, change to whatever the game requires
Dim iNrs(1 To MAX) As Boolean'assume first number = 1
Dim iCnt As Integer
Private Sub Command1_Click( ) 'clear, start fresh
Dim i As Integer
For i = 1 To MAX
iNrs(i) = False
Next i
iCnt = 0
End Sub
Private Sub Command2_Click( )'draw a number
Dim iNr As Integer
If iCnt < MAX Then
Do
iNr = Int((MAX * Rnd) + 1)'generate nr between 1 and MAX
Loop Until Not iNrs(iNr)
iCnt = iCnt + 1
iNrs(iNr) = True
Text1.Text = iNr
Else
Call MsgBox("All numbers done", vbInformation, "done")
End If
End Sub
Private Sub Form_Load()
Randomize
End Sub
[/CODE]
Comment