Just because you otherwise would have to write down:
load picture(0)
load picture(1)
...
load picture(52)
It's a little bit more dynamic
Main Topics
Browse All TopicsThis code is for my blackjack game. I thought the Picture1 was in regards to the picture box on my form which would be 1 out of 22. So I dont understand where the array comes in For i = 0 To 51.
How does this code know where to display the card that it is dealing?
For i = 0 To 51
Load Picture1(i)
Next i
For i = 0 To 51
Picture1(i).Picture = "c:\somefile" & i & ".bmp"
Picture1(i).Tag = "card value" 'ie Jc or 4h
Next i
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I know the I is an array of 52 but why is it there?
Is there no part of this code that takes into consideration that there will be between 4 and 22 cards dealt during the game of blackjack?
I have 52 pictures but its dealing any 1 of those to any 1 of 22 picture boxes I need to know about.
Cheers for help so far.
Why not put all the pictures into a resource file? Then load them as you need to display them. In any case, "Picture1" or "Picture" or "FredsPics" or "MyPics" or "YoYoLokSeeDaGoGoPics" or whatever you want to call it. That is your variable name. It doesn't matter what you name it so long as you define it properly (in this case it looks like it is an array of picture objects). Make sure you put the following at the begining of ever forms code (and modules code).
Option Explicit
That way it will force you to define all your variables and thus you would not be asking what Picture was because you could not compile your code until you defined it.
Did I already help you a bit on this subject? Let me go look at my previous post.
Definition. Well its a picture box control. Its defualt name is Picture 1. I'm trying to figure out why its a good idea to load 52 pictures into 1 picture box named Picture1 and is the loading Random. Theres 52 pictures in a file and the file name in the code uses (i) which is 52. I'm guessing my file names need to be Card 0 to Card 51.
No, I think that someone is recommending that you create an array of picture objects or an array of image objects. Then this code is simply attempting to load each file (.BMP) into the array of images or pictures. It doesn't have anything to do with displaying. When you want to display one of the 52 cards you will have to assign an image from your image array into the actual picturebox control that you have placed on your form.
Nevertheless, I think your best solution is to put all your pictures into a resource file and load them from the resources rather then loading them into one big array of images. For instance, you can download one of those Resource extractors for free (like ResHack or something). Then you can extract all the Bitmaps from the Cards.dll file in your System32 directory. ResHack will then create a seperate resource file from all of those images (actually it creates an .RC file that you need to compile into a .RES file). Then you simply include the .RES file just like you include any Form or Module in VB. Then you will use your VB resource functions to get the images you want to display directly from your resources rather then loading them from file.
Now, in the end if this is a product that you are selling you will probably want to draw your own card Bitmaps, but for the time being there isn't any problem using the ones that Microsoft provides in the Cards.DLL file.
Here....let me create a .RES for you from that Cards DLL file....hold up a sec....shouldn't take long.
Ok, here you go. This contains all the images from the Cards.DLL file and I put them into a file called MyCards.RC and then compiled the .RC into MyCards.RES. So just include MyCards.RES into your project and you will then have all the cards available in your program when it loads. Just look up how to get Bitmaps from a resource and your good to go (its basiclly the same functions that you use to get them from files). Here is the link:
http://www.enlade.com/Samp
Remember it is likely that you cannot sell any products that use this .RES file. You know you can probably just load the cards directly from the Cards.DLL file instead of putting them in a .RES of your own. Then I don't see any problem doing that since Microsoft provides the file and your just using it.
Ok, check out this program. It shuffles a deck and then displays a list of the shuffled cards in a listbox. Whenever you select any card in the listbox it will draw the picture of that card in an image box on the form. This should give you all you need to know to figure out how to write your blackjack game. Hope it helps.
http://www.enlade.com/Samp
Oh, and also the Cards.DLL had the backs of the cards as well. So resource images 53 through 65 are all the backs of the cards. Resource images 66 through 74 are just other images that the Sol.EXE (solitare) needed to do other things (like make the Sun blink at you from the backs of the cards and show blank placeholders on the table where cards can be placed, etc.) Still, you might want to make use of the 53 through 65 card backs so that your cards look nice when they are laying face down (like the dealers hidden card and the top of the deck).
I went ahead and made a little change to the BlackJackTest-b program so that it also allowed you to view the backs of the cards. If you have already download BlackJackTest-b.Zip from the above link then download it again so you have the most recent. Here is the link again:
http://www.enlade.com/Samp
Enjoy.
Business Accounts
Answer for Membership
by: DhaestPosted on 2005-02-03 at 07:13:31ID: 13215054
The i will be replace by the value from 0 to 51 (becasue there are 52 cards)