martin2k

Google
 
Web www.martin2k.co.uk

a few questions


Home Read and add posts to the Visual Basic 6.0 Forums Download some of my programs and OCXs Read the Tips here The old style forum is still available here Contact

Back


From: Dave Hildebrand E-mail: disco@air.on.ca 1

Date: Tuesday, April 10, 2001 at 03:49:11

Subject: a few questions

Comments:

im takeing VB in school right now and my text does not have the answeres to these questions:

1. to get a random number from 1-75, and not repeat numbers.(i can get random numbers) 

2. to get said numbers to show on an control button array as underlined ( its a bingo board, number drawn is "stamped" and cannot be drawn again)

any ideas would be great..even links to sites that would have that info

From: Martin Allen E-mail: <No e-mail> 2

Date: Wednesday, April 11, 2001 at 23:07:43

Subject: RE: a few questions

Comments:

I hope the following code will help you with your problem:

Dim i(15) As Integer 'Change 15 to something else if it is not right

Sub Bingo()
Dim Nxt As Integer, Nxt2 As Integer
Randomize
Nxt = 1
    Do Until Nxt = 16
redo:
    Nxt2 = 1
    i(Nxt) = Int((75 - 1 + 1) * Rnd + 1)
        Do Until Nxt2 = Nxt
        If i(Nxt) = i(Nxt2) Then GoTo redo
        Nxt2 = Nxt2 + 1
        Loop
    Nxt = Nxt + 1
    Loop
End Sub

Private Sub Form_Click()
Bingo
MsgBox i(1) & ", " & i(2) & ", " &i(3) & ", " & i(4) & ", " &i(5) & ", " & i(6) & ", " &i(7) & ", " & i(8) & ", " &i(9) & ", " & i(10) & ", " &i(11) & ", " & i(12) & ", " &i(13) & ", " & i(14) & ", " &i(15)
End Sub

The 'Bingo' procedure will generate the random numbers between 1 and 75 and will store them in the variable i(1) to i(15) (if there are 15 numbers on a Bingo board?).  No two numbers will be the same.  When the event to call the numbers happens, just pick a number between 1 and 15 and use it i (<here>).


This forum is no longer taking new messages or replies since 01 November 2002.  The above material is for reference purposes only.

The new Visual Basic 6.0 forum can be found here.


Martin Allen 1999 - 2003.  Last updated Monday 12 May 2003 07:55:24 PM +0100.