Hello, here is my issue.

I am having users load images into the application resouces to be used by the application to display them in a random matchup game.

I cannot see how I would code to know how many images are in the folder, how to make 2 images somehow pair up, and then randomly display them, any help would be greatly appreciated.

8 Years
Discussion Span
Last Post by SCBWV

Use a for/next loop to load the images from disk. If the number of images loaded is not evenly divisible by 2, you have a problem, since you can't match up an odd number of images. Use 2 image control arrays. Inside the loop, as each image file is read, load the same file in both image arrays, thus creating matched pairs. If you do it this way, it will be easy to tell if the user selects a match because each matched pair will have the same index number. For example Image1(1) will have the same picture as Image2(1), Image1(2) will have the same picture as Image2(2), and so on. You'll need code to randomly arrange the two image arrays on the screen.


Good info I appreciate that, any chance somone can show me what the code might start out like for something like that? I'm unfamiliar with how to read files from my resource folder, and I could use help with that. =\
thank you!


Create two Image control arrays. Then use a loop to load each picture as shown below

JPegPath$ = "C:\My Pictures\"
PicFile$ = Dir$(JPegPath$ & "*.jpg")
Inx = 1
Do While LenB(PicFile$) > 0
   Load Image1(Inx)
   Load Image2(Inx)
   Image1(Inx).Visible = True 
   Image2(Inx).Visible = True
   Image1(Inx).Picture = LoadPicture(JPegPath$ & PicFile$)
   Image2(Inx).Picture = LoadPicture(JPegPath$ & PicFile$)
   Inx = Inx + 1
   PicFile$ = Dir$
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.