Here is how I do it. Basically you need a graphic box in your window. Your pictures should be in a folder of it's own and you need to know how many pictures there are. The pictures can be smaller than the graphic box but not larger.
First I put all the picture names in a ListBox to make the search easier.
I forgot this line first.
To be more precise for the next person you also need somewhere
LastPicture=val(info$(0,0)) 'This is the number of pictures. if LastPicture>0 then 'If there are no pictures. redim ListBox$(LastPicture) for x=1 to LastPicture ListBox$(x)=info$(x,0) 'This puts each name in the list box and it contains the .bmp next sort ListBox$(, 1,LastPicture 'Sort the names in alphabetical order. end if
Next select the item from the list box. My code looks like this. #breedlist.lb1, "selection? breed$" 'The breed$ does not contain the .bmp
Then I call a sub routine that will place the picture in the graphic box. call PlacePicture breed$, LastPicture LastPicture is the number of pictures in your folder.
Here is the subroutine. sub PlacePicture brdname$, lastpic 'Place breed pictures. #breedlist.grb1, "cls; fill buttonface" 'Clear the graphic box first because there is still a picture in it. I use the window color. for x=1 to lastpic 'lastpic is the number of pictures a$=upper$(upto$(ListBox$(x),".")) 'Do the search in upper case so you find the right picture in the ListBox without the .bmp if upper$(brdname$)=a$ then exit for 'Once you find the right picture exit the loop next if x>lastpic then 'No picture found. 'In case the picture isn't found. loadbmp "picture", DefaultDir$+"\bmp\"+"No Picture.bmp" 'This is bmp that says "No Picture Found". else 'Picture found. loadbmp "picture", DefaultDir$+"\"+FOLDER$+" Pictures\"+brdname$+".bmp" 'Now load the right picture. end if #breedlist.grb1, "drawbmp picture 0, 0; flush" 'Put it in the graphic box. unloadbmp "picture" 'Then unload the picture for the next one. It will stay in the graphic box until it is cleared. end sub
Last Edit: Dec 5, 2019 10:24:37 GMT -5 by mknarr: Forgot several necessary lines of code.
I created a folder with .bmp files and ran the code, but it gives me an error stating it is not a multi-dimensional array. When I change it to single, it gives an "isEmpty" not understood. I am evidently doing something wrong.
Post by Chris Iverson on Dec 4, 2019 19:47:00 GMT -5
Don't worry about it. God only knows how many times I've forgotten something simple in something I've posted for others here. In one of my most recent posts you'll find I edited it because I left something out