Results 1 to 3 of 3

Thread: Allocating files to listbox values

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    1

    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!

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    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!

  3. #3
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    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
  •  



Click Here to Expand Forum to Full Width