Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Blackjack


  • Please log in to reply

#1
trogdor

trogdor

    New Member

  • Member
  • Pip
  • 1 posts
:tazz:


ok, so our VB.net teacher is making us do this ridiculous project where we have to program a game of blackjack. i know how to make the buttons (hit, stand, clear, exit) and such, not a prob. thing is, we have to make a random card appear in a picture box control, and i dont know how to make the picture box respond to the Hit button. basically, i need a card image to pop up in the picture box when i click the Hit button. oh..and we're not allowed to use advanced stuff like shells or anything; we've only learned as far as loops. i need help ASAP.
  • 0

Advertisements


#2
senshisteph

senshisteph

    Member

  • Member
  • PipPip
  • 41 posts
Sounds similar to the dice game I had to do when learning VB6... well it was a while ago but I can give you a rough gist of what to do and you can look up the correct code later.

First you need a set of images of playing cards.

This bit goes in the general area:
Set up an array (if you have covered those yet - otherwise you will need a couple of fairly lengthy case statements) with 3 sets of values - a number 0-51, an image filename, and the numerical value of the card.


Attach the stuff below to the button:
The first thing the button should do is generate a random number 0-51. Save it as a variable e.g. HitNum
Use either the array values to set the image displayed and add the correct number of points to the total. (I would need to look this up - like I say it has been a while)
OR
set up 2 case statements (these are going to be long):

select case HitNum
Case='0' then Pictbox.image='aceofspades.jpg'
Case='1' then pictbox.image='twoofspades.jpg'
(etc - this may not be exactly right but kind of like that)
End case

Select case HitNum
Case='0' then PointsTotal=PointsTotal + 11
(you might want to add an extra bit in here which changes the Ace values to +1 rather than +11 if the PointsTotal is more than 21)
...etcetera

Finally a simple if statement to see whether points total is more or less than 21.


Hope this helps!
  • 0

#3
senshisteph

senshisteph

    Member

  • Member
  • PipPip
  • 41 posts
Duh - if you use numbers 0-51 to name the images you can just get it to append .jpg to the number and change the picture.image to whatever that value is.

Um, I think, anyway. It would get rid of the first case statement.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP