Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image appear many times

Status
Not open for further replies.

philipad

Technical User
Feb 12, 2006
23
CY
HI all

I want to place an image in more than one places in the form of a program. For example to place the image to one position of the form I use this in then code...

img1.Left = 100
img1.Right= 200

Now I want to place this image in other place using the same image file.

Anyone can help me?
 
Create your first image control with an Index value of 0. You can then add further further image controls as an array at runtime. Use the Load command in a loop construction, and set up the .Top and .Left positions calculated from the array index. Quick example for producing a 3 x 4 array (note no errorchecking, this is NOT production code!)
Code:
Private Sub cmdPic_Click
Dim a As Integer
Dim baseL As Long
Dim baseT As Long
Dim baseW As Long
Dim baseH As Long
With Image1(0)
baseL = .Left
baseT = .Top
baseW = .Width
baseH = .Height
End With
For a = 1 To 11
Load Image1(a)
With Image1(a)
.Left = baseL + ((a Mod 3) * baseW)
.Top = baseT + ((a \ 3) * baseH)
.Visible = True
End With
Next a 
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top