Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bingo Card Creation 2

Status
Not open for further replies.

dodge20

MIS
Jan 15, 2003
1,048
US
Hello All,

I need some advice. I was assigned to create a bunch of bingo cards. I need to create a bunch of different cards, so I would like to have the numbers picked at random. I also would like this to create a specified amount of cards.
What would be the best way to go about doing this. I assume I will have to write a module to accomplish this.

Any suggestions would be greatly appreciated.

Dodge20
 
First I would create 25 Text Boxes, and name them txtB1, txtB2, txtB3, txtB4, txtB5, txtI1, ...txtI5, txtN1, ...txtN5, and for G and O as well. Then drop in a button cmdBingo and use the following code in the click event.
Code:
Private Sub cmdBingo_Click()

   Dim TheCols(4) As String
   Dim Idx As Integer
   
   TheCols(0) = "B"
   TheCols(1) = "I"
   TheCols(2) = "N"
   TheCols(3) = "G"
   TheCols(4) = "O"
   
   For Idx = 0 To 4
      GenerateColumn Idx, TheCols(Idx)
   Next Idx
   Me.Controls("txtN3") = "X"
   
End Sub

Private Sub GenerateColumn(Offset As Integer, ColID As String)

   Dim Idx As Integer
   Dim TheVals As New Collection
   Dim Index As Integer
   
   For Idx = 1 To 15
      TheVals.Add Idx + (Offset * 15)
   Next Idx
   
   Randomize
   For Idx = 1 To 5
      Index = Int((Rnd * TheVals.Count) + 1)
      Me.Controls("txt" & ColID & Trim(Idx)) = TheVals.Item(Index)
      TheVals.Remove (Index)
   Next Idx
   Set TheVals = Nothing

End Sub
Thanks for the diversion. Given my day, it was nice to take a break and do something fun.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks, I will taylor this to what I need.

Dodge20
 
A star from me too! It even put the FREE SPACE in the middle box! Impressive.

Jim DeGeorge [wavey]
 
Is there anyway to create a bunch of these, let's say 300, so I can't print them easily?

Dodge20
 
Create a table, and bind the textboxes to that table. Then create an outer loop to call this process how every many times you need, with each time adding a new record to the table. The build your report and off you go.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top