|
-
Apr 24th, 2010, 03:33 AM
#1
Thread Starter
New Member
Allocating files to listbox values
Hi. I am making a card game and need some help. I'm pretty new to programming in general but don't know much of the command syntax in VB which is my main problem.
How would I go about setting different values in a listbox to different files in my directory? What I mean is, say '1' was the first number in a list of 52 randomly ordered numbers (1-52) in a listbox. I want this to load a certain image. Therefore '2' would load another image, and so forth all the way to 52. Atm everytime the form loads the numbers are randomly ordered (cards are shuffled).. that's done, but basically I just need to link each number to a file so the program can load the cards in order.
What would be the best way to do this? Assistance please!
-
Apr 24th, 2010, 07:17 AM
#2
Frenzied Member
Re: Allocating files to listbox values
So you have made 52 of your own images for the cards and are not using those in the cards.dll or the cards32.dll that all the M$ games use???
Okay, if list1.list(0) = 1 and your file name is say 01.jpg then you can do Picture1.Picture = LoadPicture(App.Path & "\" & Forma(List1.List(0), "00") & ".jpg"
Good Luck
Option Explicit should not be an Option!
-
Apr 24th, 2010, 07:25 AM
#3
Re: Allocating files to listbox values
Create a string array to hold the list of file paths. Then when you load the
listbox, populate the array with the file path and give each listbox item's ItemData the index
into the array.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|