Solved

Visual Basic help

Posted on 2002-04-15
14
187 Views
Last Modified: 2013-11-25
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.
0
Comment
Question by:Linky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 2
  • +1
14 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6943245
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.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6943435
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
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 50 total points
ID: 6943439
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
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:rspahitz
ID: 6943443
Hmm...EE glitch...
0
 
LVL 2

Author Comment

by:Linky
ID: 6943509
Thanks a lot.
0
 
LVL 1

Expert Comment

by:ProgramIT
ID: 6943979
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.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6944697
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
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6946240
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.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6946743
I agree.
Hi Linky, any comments?
0
 
LVL 2

Author Comment

by:Linky
ID: 7136452
Thank you for your help all.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7138866
You're welcome.

And thanks for closing the Q and thanks for the "A" grade.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7138953
...and is there, at least, a little "thanks" to me?
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7138963
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.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7138978
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 ;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SAPE.heur.AE935 Visual Studio 3 74
Spell Check in VB6 13 146
how to know if my Checkbox is True in VB6.0? 9 68
Publisher:   Unknown     VB.exe Application 1 31
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question