Question

Picture1(i) - Why does this need the (i)

Asked by: TycoonMillion

This 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.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2005-02-03 at 07:07:53ID21300303
Topic

Visual Basic Programming

Participating Experts
3
Points
200
Comments
25

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

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.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

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.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

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.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. BMP files
    Ok, I need a BMP reading procedure. But not just any one. I have one that I used in 256 color, but now I'm using 16-bit color. It's ok if the procedure only loads up 24-bit BMP's only. (Ever see a 16-bit BMP?) So no one trys to tell me somthing I know, I can read the hea...
  2. call IE  by OLE container in picture1 container.
    Hihi, I am beginner of vb programmer. I suggest want to implement a vb program that can call windows application and display on the vb form. For Example: when I click on command1 button, then it will call IE and display c:\ie.html file, but this application must in Picture1...
  3. Save picture box to gif or bmp?
    Is it possible to save the visual data of picture1 to a gif or bmp file?
  4. Monochorme BMP in 1s and 0s
    Hi experts, I am in a real fix (like always) I have a monochorme BMP (2 color - blank and white) All I want to do is save its structure in a text file as 1s and 0s. I am facing real problem in doing so and like always project is due in coming week. I would really really r...
  5. Help about :    Load picture1(index) ..........
    Hello Experts , i have taken a array of Picture Box (Picture1(0)) i load remaining 10 picture boxes as for i=1 to 10 load (picture1(i)) picture1(i).visible=true next i Now if i removed control array number 4 as :- unload picture1(4) and if i want to ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

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.

Join the Community

Answers

 

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)

 

by: DhaestPosted on 2005-02-03 at 07:14:10ID: 13215063

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

 

by: ryancysPosted on 2005-02-03 at 07:36:05ID: 13215320

Array is always starts from 0, if your array keep 52 elements, so the array index with start from 0 and ends with 51

 

by: TycoonMillionPosted on 2005-02-03 at 07:36:52ID: 13215327

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.

 

by: DhaestPosted on 2005-02-03 at 07:38:13ID: 13215346

The loop is just for loading the 52 cards in an array, which then can be used in your program

 

by: TycoonMillionPosted on 2005-02-03 at 08:07:15ID: 13215717

So what is picture1? Why cant it just be Picture(i)?

 

by: DhaestPosted on 2005-02-03 at 08:10:58ID: 13215776

Check you components at your form, and see what's named "picture1". I guess one of the picture boxes....

 

by: EnladePosted on 2005-02-03 at 08:17:28ID: 13215856


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.

 

by: DhaestPosted on 2005-02-03 at 08:19:41ID: 13215892

No offence, but I'm getting the idea that you haven't got any programming experience (if I look also look at your other question) or perhaps programming experience but not in visual basic.
My suggestion: first start reading a book, tutorials, ... with an introduction to vb.

 

by: TycoonMillionPosted on 2005-02-03 at 08:26:22ID: 13215989

How about just telling me what this code does. Does is load 52 cards or does it deal 1 card to 1 picture box?

 

by: DhaestPosted on 2005-02-03 at 08:28:43ID: 13216029

Can you first do a search for me what's the definition of Picture1 ?

Is it a visible object (fe listview, ...) , is it a custom object ?

 

by: TycoonMillionPosted on 2005-02-03 at 08:31:48ID: 13216078

To me it looks like all 52 cards are loaded into Picture1 because I was told that this code is what I needed to load my 52 pictures.

 

by: TycoonMillionPosted on 2005-02-03 at 08:35:53ID: 13216133

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.

 

by: DhaestPosted on 2005-02-03 at 08:38:34ID: 13216171

I guess it's a better idea to generate a random number between 0 and 51 and load and show that file instead of loading all files..

i = Int((51 - 0 + 1) * Rnd + 0)
Picture1(i).Picture = "c:\somefile" & i & ".bmp"
Picture1(i).Tag = "card value" 'ie Jc or 4h

 

by: TycoonMillionPosted on 2005-02-03 at 08:42:08ID: 13216209

Ye I know that but can you just confirm that this code
i = Int((51 - 0 + 1) * Rnd + 0)
Picture1(i).Picture = "c:\somefile" & i & ".bmp"
Picture1(i).Tag = "card value" 'ie Jc or 4h

would only do 1 single picture box on my form please.

 

by: DhaestPosted on 2005-02-03 at 08:42:58ID: 13216226

It would indead do only the picturbox, named "picturebox1"

 

by: EnladePosted on 2005-02-03 at 08:45:28ID: 13216264


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.

 

by: TycoonMillionPosted on 2005-02-03 at 08:47:53ID: 13216298

Cool thats what I thought and I was just making sure.

Cheers.

 

by: EnladePosted on 2005-02-03 at 08:50:20ID: 13216323


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.

 

by: EnladePosted on 2005-02-03 at 08:55:23ID: 13216388


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/Samples/Cards.zip

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.

 

by: EnladePosted on 2005-02-03 at 10:50:45ID: 13217750


Just to be complete let me add the displaying of the cards to that other little program that I gave you.  Hold up a bit....will take a few minutes.

 

by: EnladePosted on 2005-02-03 at 11:01:17ID: 13217876


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/Samples/BlackJackTest-b.zip

 

by: EnladePosted on 2005-02-03 at 11:04:13ID: 13217908


Oh, and that other link to the cards resource file isn't good.  The cards resource need to be edited a little bit to get it to work with VB.  I did that minor editing and the real cards resource file is found in a subdirectory of the above zip file (BlackJackTest-b.zip).  Use that instead.

 

by: EnladePosted on 2005-02-03 at 11:08:50ID: 13217963


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).

 

by: EnladePosted on 2005-02-03 at 11:19:46ID: 13218097


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/Samples/BlackJackTest-b.zip

Enjoy.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...