ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loading images (https://www.excelbanter.com/excel-programming/296491-loading-images.html)

Jason Morin[_3_]

Loading images
 
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason

Rob Bovey

Loading images
 
Hi Jason,

You can't concatenate object names like that. You'll have to do it with
three separate lines of code (or do something more complex, like set the Tag
properties of each image control, then loop the whole controls collection
and identify them by their Tag).

Game.Image1.Picture = LoadPicture("C:\....")
Game.Image2.Picture = LoadPicture("C:\....")
Game.Image3.Picture = LoadPicture("C:\....")

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Jason Morin" wrote in message
...
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason




Doug Glancy

Loading images
 
Jason,

Try this:

Game.Controls("Image" & i).Picture = LoadPicture("C:\....")

hth,

Doug Glancy

"Jason Morin" wrote in message
...
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason




Juan Pablo González

Loading images
 
What I do is this:

For i = 1 to 3
Game.Controls("Image" & i).Object.Picture = LoadPicture("C:\...")
Next i

--
Regards,

Juan Pablo González

"Jason Morin" wrote in message
...
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason




Jason Morin[_3_]

Loading images
 
Thanks! That did the trick.

-----Original Message-----
Jason,

Try this:

Game.Controls("Image" & i).Picture = LoadPicture

("C:\....")

hth,

Doug Glancy

"Jason Morin" wrote

in message
...
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason



.


Jason Morin[_3_]

Loading images
 
Gracias. Ahora funciona perfectamente.

-----Original Message-----
What I do is this:

For i = 1 to 3
Game.Controls("Image" & i).Object.Picture =

LoadPicture("C:\...")
Next i

--
Regards,

Juan Pablo González

"Jason Morin" wrote

in message
...
I'm loading pictures into Image1, Image2, Image3 on a
useform called "Game". Here's what I have:

For i = 1 To 3
Game.Image & i.Picture = LoadPicture("C:\....")
Next i

The "Image & i" is erroring. What's the correct syntax?
Thx.
Jason



.



All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com