Link to home
Start Free TrialLog in
Avatar of Linky
Linky

asked on

Visual Basic help

Now, I want to know something in Visual Basic. I made the declaration:

Dim X(0 To 10, 0 To 1) As Image

Now say I wanted the image in X at 1,1 to be pic1.bmp, and the one a 2,1 to be pic2.bmp? What I am getting at is building a map from a bunch on images in an array. How do I go about doing it? Of course each image will be stored in different spaces (e.g. 16 by 16 tiles). Can someone help me? Code would help.
Avatar of Richie_Simonetti
Richie_Simonetti
Flag of Argentina image

Create an array of singles or longs, open each picture with loadpicture function and use paintpicture function to paste each image in a picture box control with a for next loop.
I agree with Richie.  There's no need to load the images into an internal array unless you plan on using them for many different things, in which case a control array may be more appropriate:

Create Image1(0), visible=false
At runtime:

For i=0 to 10
  for j=0 to 1
    Load Image1(i*2+j)
    with Image1(i*2+j)
      .Picture = LoadPicture([filename,maybe from an array])
      .move [left],[top]
      .visible=true
    end with
  next j
next i

Depending on the fileformat, this may be easy.  Also, depending on the file sizes, the [left] and [top] values may be calculated or may need a calculation to determine where the last one went.  If they're 16x16 as you indicate, then use:  .move i*16, j*16 ' or j*16, i*16 for 2 columns
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmm...EE glitch...
Avatar of Linky
Linky

ASKER

Thanks a lot.
I'd suggest using the Microsoft PictureClip control .  Define the are in Rows and Columns and then the map can be loaded as one complete pic but section are available
Then by using GraphicCell(CellNo you can access individual sections.
Place a PictureClip on a form. Load the full image.
Set the number of Rows and Columns you want the picture split into.
Then if you wanted to show just the 3rd section in a seperate picturebox then
Picture1.Picture = PictureClip.GraphicCell(3)
Note the PictureClip is not visible during running.
I found the PictureClip also very handy for things like graphic interfaces etc.  Where numerous pictures are required for buttons etc, with using one complete graphic of the whole thing.
Just a thought, Hope it helps.
Nice comment ProgramIT, but in this case i think, we are talking of different images (overlapped?) not a split of one.
Linky, do you need more code/help? Just ask.
Cheers
ProgramIT, I just played with the PictureClip control and it will definitely find a place in my future...thanks!

But as Richie said, I think the question here is the opposite: how do I assemble those pictures...I think that nce they're assembled into a picturebox, the remaining image could be saved then the PictureClip control could be used as the storage array to access individual pieces (assuming they're all the same size.)  This Q seems to be an issue of showing all at once, not just the the parts.
I agree.
Hi Linky, any comments?
Avatar of Linky

ASKER

Thank you for your help all.
You're welcome.

And thanks for closing the Q and thanks for the "A" grade.
...and is there, at least, a little "thanks" to me?
Richie, the "I agree with Richie" sentence and "Thank you for your help all." (Linky) wasn't good enough?

  OK then---thanks, Richie! :)  Muchas gracias. Merci beaucoup.
rspahitz, since answer raised from my comment, i would like a "specific" thanks from Linky, that's all!
(I just remember one comment from you in another thread ;)