Solved

Visual Basic help

Posted on 2002-04-15
14
162 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
  • 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now