?
Solved

Visual Basic help

Posted on 2002-04-15
14
Medium Priority
?
198 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 200 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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