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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seeding Values

Status
Not open for further replies.

MrMoocow

Programmer
May 19, 2001
380
US
This will get the job done on how to seed values.
Example to make a card deck you would detirmine the number before hand, so you would have this (3.4.5.2.1) and you fould know that the third card is first.

The only thing wrong is I can't dynamicaly dim arrays. So I fixed it one to fifty.

Please any question comments or anything post em!

Ps: Is this FAQ or not?


Code:
Public Function MakeDeck(low As Integer, high As Integer)

Dim take(1 To 50)

For i = low To high
repeat:
num = Rnd2(low, high)
If take(num) = "Yes" Then
GoTo repeat
Else
MakeDeck = MakeDeck & num & ","
take(num) = "Yes"
MsgBox MakeDeck
End If

Next i

For i = low To high
take(i) = ""
Next i


End Function


Public Function Rnd2(ByVal low As Single, ByVal high As Single) As Single
Randomize
Rnd2 = Rnd * (high - low) + low
Rnd2 = Round(Rnd2)
End Function
Brad,
Free mp3 player,games and more.
 
OOOOOOooooooooooooPPPPPPSSSSSSSS Silly me I left the debug msg in.

Remove the Msgbox.

Sorry Brad,
Free mp3 player,games and more.
 
Brad -

Don't forget that for the second draw, there's only 51 cards left. And for the third draw, there's only 50 left, etc.

If you were to have the Ace of Spades in there multiple times, well, in Texas that might still be a hanging offense.

Chip H.
 
Okay you may have misintpreted how this works.....

CurrentCard = CurrentCard + 1
NewCard = Card(CurrentCard)

Now Newcard has a value of say 13 or 11 or whatever and Using your own function it will load 13 which is Queen I think.

Since Current Card is plus one this elimantes any chance of Duel Cards.


Regards.
Brad,
Free mp3 player,games and more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top