1 RRS feed

All replies

  • Hi,

    You can store anything in a Small Basic array, including images (just like how you did with Rectangles), using ImageList.LoadImage.  You have to give it a web or local file path to each image - missing in example below.

    Store images in an array
    For i = 1 To 5
      For j = 1 To 5
        images[i][j] = ImageList.LoadImage("url to image")
    'Show random image
    i = Math.GetRandomNumber(5)
    j = Math.GetRandomNumber(5)

    Friday, October 17, 2014 7:56 PM
  • yes, so how could i change the image which is stored every time it goes around the loop? Should i store them all in an ordinary array first? Then pull the from it into the new one?

    Also how could i give a value to each image? I need to do this because it is for a card game (like poker)

    Saturday, October 18, 2014 11:20 AM
  • You do need to store all the images - to do this in a loop it may be best to name them in a numbered way like:

    image1.jpg image2.jpg etc

    then load them in a loop as : image[i] = ImageList.LoadImage("C:/mypath.../image"+i+".jpg")

    or for cards:

    club1.jpg ...club13.jpg etc.

    The image is effectively numbered by the index in the array.

    Saturday, October 18, 2014 11:24 AM
  • Yeah, thats how i thought i could do it but i then have to load them randomly. How could i link a value to the card?
    Saturday, October 18, 2014 1:36 PM
  • The index in the array identifies the card.  You could have another array with a value for each card indexed in the same way as the images so that the same index refers to the image and value in the different arrays. 

    Or you could use multi-dimensional arrays - probably harder to code and may be slower, but some may prefer this approach for aesthetic reasons.

    To get random caards just choose an index randomly as I did in the small example posted.

    Sunday, October 19, 2014 12:25 AM