Solved

# Copying Properties from one Image or Picture box to another

Posted on 1998-11-02
163 Views
I am creating a tile-base game and have been putting image boxes on a form.  I want to be able to save the properties )height, width, etc) of one image box and paste them to the form making a grid of equal sized "tiles".  I am doing it the hard I way I think by slapping an image box on the form and then modifying properties for Height. Left, Top & Width.  Height & Width should stay the same, but the Top and Left properties change depending on where on the form the image box is located.  With 15 x 15 pixel image boxes, this is very tedious.  Any ideas?  Thanks.  --Vingamel
0
Question by:Vingamel
[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
• 6
• 3

LVL 3

Accepted Solution

ID: 1442975
Use an array of images.
225 of them in your case.. 0 to 224
Dim TheWidth as single
TheWidth = imgTile(0).Width
TheHeight = imgTile(0).Height
for x = 0 to 14
for y = 0 to 14
imgTile(y * 15 + x).Move x * TheWidth, Y * TheHeight
next y
next x

0

LVL 3

Expert Comment

ID: 1442976
oops.. dont forget the
Dim TheHeight as single
0

LVL 3

Expert Comment

ID: 1442977
Here is something that will be ok..

Private Sub Form_Click()
Dim TheWidth As Single
Dim TheHeight As Single
Dim x As Integer
Dim y As Integer
For x = 1 To 224
Next x
TheWidth = imgTile(0).Width
TheHeight = imgTile(0).Height
For x = 0 To 14
For y = 0 To 14
imgTile(y * 15 + x).Move x * TheWidth, y * TheHeight
Next y
Next x
For x = 1 To 224
imgTile(x).Visible = True
Next x

End Sub
0

LVL 1

Author Comment

ID: 1442978
Thanks...Code looks like it should work fine.  You are an Expert.   --Vingamel
0

LVL 1

Author Comment

ID: 1442979
Thanks...Code looks like it should work fine.  You are an Expert.   --Vingamel
0

LVL 1

Author Comment

ID: 1442980
Thanks...Code looks like it should work fine.  You are an Expert.   --Vingamel
0

LVL 1

Author Comment

ID: 1442981
I got this stuff to work great except for two problems:
1) Low resource & memory errors...is there a more efficient way of doing this than with a control array of bitmaps?
2) the first tile in the control array (Image1(0).Visible) cannot be changed to False...it is always visible even when I change value of all tiles to Visible = False.  When I run it, it blinks for a second, then the image tile becomes visible again.  Any clues?  Thanks.  --Vingamel
0

LVL 1

Author Comment

ID: 1442982
I got this stuff to work great except for two problems:
1) Low resource & memory errors...is there a more efficient way of doing this than with a control array of bitmaps?
2) the first tile in the control array (Image1(0).Visible) cannot be changed to False...it is always visible even when I change value of all tiles to Visible = False.  When I run it, it blinks for a second, then the image tile becomes visible again.  Any clues?  Thanks.  --Vingamel
0

LVL 13

Expert Comment

ID: 1442983
Bought This Question.
0

LVL 1

Author Comment

ID: 1442984
What do you mean "Bought this Question"  Thanks.
0

## Featured Post

Question has a verified solution.

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

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â€¦
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describesâ€¦
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). Uâ€¦
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â€¦
###### Suggested Courses
Course of the Month8 days, 14 hours left to enroll