Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a VB.NET Expert!

Join 415,722 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,363 people online right now.Registration is fast and FREE... Join Now!



Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

Vb.net generate non repeating number/non repeating card by dealing trying blackjack card game but about to...oneself not able to do this. Rate Topic: -----

#1 XMEGA  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 2
  • View blog
  • Posts: 100
  • Joined: 17-November 08


Dream Kudos: 0

Share |

Vb.net generate non repeating number/non repeating card by dealing

Post icon  Posted 17 November 2008 - 11:41 AM

I am making a card game "Blackjack", but for simplicity purposes I will dumb it down a little for my understanding...I want to click a button and I want to generate 4 numbers. Place each number into the 4 textboxes but none of them be the same...

randomCard = randomGenerator.Next(1, 5)

example:
click button "DEAL"
textbox 1 fills in with "3"
textbox 2 fills in with "1"
textbox 3 fills in with "2"
textbox 4 fills in with "4"

I want this is a while loop too I think...

---

Here is what I have/trying to do currently working with just "aces" card type and dealing 2 cards for player 1...
I have a dummy picture box which generates a card but I want that dummy card to pass off its image to "P1C1 = player 1 card 1" and then I want it too generate another random number again but it cannot be the came number as the card is already dealt down...this new number should be different and then deal to "P1C2 = player 1 card 2"

Private Sub GenerateRandomNumber()
		'generates random numbers

		Dim count As Integer = 0
		Dim cardUsed As Integer = 0


		While cardUsed = 0
			randomCard = randomGenerator.Next(1, 5)

			count = count + 1
			cardUsed = cardUsed + 1

			If randomCard = 1 And cardUsed = 1 Then
				xCard.Image = xAceClubs.Image
			ElseIf randomCard = 2 Then
				xCard.Image = xAceSpades.Image
			ElseIf randomCard = 3 Then
				xCard.Image = xAceHearts.Image
			ElseIf randomCard = 4 Then
				xCard.Image = xAceDiamonds.Image
			End If


			If count = 1 Then
				xP1C1.Image = xCard.Image
			End If

			If count = 2 Then
				xP1C2.Image = xCard.Image
			End If

		End While


This post has been edited by XMEGA: 17 November 2008 - 11:55 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users