Picture box with multiple images..

I have a single picture box which holds little gif's for whichever die was rolled when my roll function is called.  The picture is updated according to whichever die was last rolled.  This works fine and dandy, but my pictures always have to be in a certain folder for it to work.  Is there anyway to embed the pictures into the program when it's compiled?  Actually there must be a way because my teacher's program doesn't have any seperate gif's and it still works.  

Thanks in advance.
BradHarrisAsked:
Who is Participating?
 
JacamarConnect With a Mentor Commented:
Well, there are some very non-elegant ways to do this.  One way to do it is to have invisible image controls that you can use to load the images in to the picture boxes.  

or.

Depending on how many options there are, you could have numerous picture boxes on top of each other, each pre-loaded with an image, and when the dice is rolled, you can bring whichever one you want to the top (visible), and when you want to have it blank, bring a blank picture box to the top.

Well, there are probably better ways, but this way will work.
0
 
JH0401Commented:
You need to have the picture file in the location that is specified by your code or that you choose in design mode when you set the picture box picture property.  Your program will look to this location to find the specified picture to display!!!
0
 
timd_jonesCommented:
Jacamar's solution is good. You can also look at using resource files, and learn how to use the requisite API calls to retrieve the images. Look at the image list control as well.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
BradHarrisAuthor Commented:
I had thought of those ways already but I don't see how that will help with my problem.  What I want to be able to do is just send out the EXE and the images should already be loaded along with it.  I don't want to send multiple files... that's how my teacher did it.  Tim's suggestion sounds good but could you direct me towards a specific source or tutorial?  Thanks
0
 
JH0401Commented:
Once you create a installation package with your package & deployment wizard (or other packaging program), the dependency files will be installed with the exe as long as you choose to include these files in the packaging!!!
0
 
timd_jonesCommented:
If you use the invisible image controls method, or multiple layered picture boxes, each with the appropriate graphic loaded in it, then the graphic binary is stored in the form's .frx file and will be compiled into the .exe.

For example:

Start a standard exe project and place on the form a picture box (Picture1), six image controls (Image1) and a command button (cmdRoll). Set the Index property for the image controls for index 0 through 5, and set each image controls Visible property to False

Private Sub cmdRoll()
    Dim lngRoll as Long

    'generate your random roll
    lngRoll = Int(Rnd * 6) + 1

    Picture1.Picture = Image1(lngRoll - 1).Picture
End Sub
0
 
JacamarCommented:
Exactly.  All the pictures are already there, just like the command buttons or the labels don't need files to go along with them.  They are saved as part of the exe.
0
 
BradHarrisAuthor Commented:
Ok that seems to be a good explanation except for the fact that I can't find an image control... I'm using VB .NET .....
0
 
JacamarCommented:
use different picture boxes then
0
 
timd_jonesCommented:
Whoops! Sorry, this code would work fine for VB5 or VB6, but not VB.Net. I don't have the expertise in VB.NET yet, else I would offer more!
0
 
BradHarrisAuthor Commented:
Thanks for spending the extra time and comments to help me get through this one.  I appreciate it!
0
All Courses

From novice to tech pro — start learning today.