Very basic question, please

K

kirkm

This must be blindingly easy, but I can't figure it.

The working example is -

frmSerial.imgLabelA.Picture = frmLabelIcons.imgDecca.Picture

However, the 'imgDecca' bit is a variable string. So how do you
properly code the equivalent of this -

frmSerial.imgLabelA.Picture = frmLabelIcons. & "imgDecca" & .Picture

I've tried everything I can think of ! Brackets, CStr... you name it.
They all fail.

Thanks for any help.

Cheers - Kirk
 
J

John_John

Hi!

frmSerial.imgLabelA.Picture =LoadPicture(imgDecca)

imgDecca must be a full fille name string (path and fillename) of the picture.

John

Ο χÏήστης "kirkm" έγγÏαψε:
 
G

Gary''s Student

I don't know what references/objectmodel you are using, but perhaps:
imgDecca
is an Object of some kind, then:

Dim MyImage as Object ' or whatever is appropriate
..
..
..
Set MyImage=imgDecca
frmSerial.imgLabelA.Picture = frmLabelIcons.MyImage.Picture

You would then vary the Set to pick up the proper picture
 
R

Rick Rothstein

I think you are looking for this...

frmSerial.imgLabelA.Picture = frmLabelIcons.Controls("imgDecca").Picture
 
K

kirkm

I think you are looking for this...

frmSerial.imgLabelA.Picture = frmLabelIcons.Controls("imgDecca").Picture

Rick, one last request :)

What if the required image for frmSerial.imgLabelA.Picture is the
default? The one that's embedded in the Form - and shows if the above
line is not executed?

I've found calling it what it's been changed to, and now is, doesn't
really work ROFL...

Thanks - Kirk
 
R

Rick Rothstein

I think you are looking for this...
Rick, one last request :)

What if the required image for frmSerial.imgLabelA.Picture is the
default? The one that's embedded in the Form - and shows if the above
line is not executed?

I've found calling it what it's been changed to, and now is, doesn't
really work ROFL...

I'm not exactly sure what you mean when you say "calling it what it's been
changed to". As for what I think you might be describing, all I can say is
it works for me. To recap... I assigned a picture to imgLabelA via the
Properties Window, ran the UserForm it is located on and executed the line
of code I posted (from a CommandButton on the UserForm)... the pre-assigned
picture from the Properties Window was replaced by the picture from imgDecca
on the other UserForm.
 
K

kirkm

I'm not exactly sure what you mean when you say "calling it what it's been
changed to". As for what I think you might be describing, all I can say is
it works for me. To recap... I assigned a picture to imgLabelA via the
Properties Window, ran the UserForm it is located on and executed the line
of code I posted (from a CommandButton on the UserForm)... the pre-assigned
picture from the Properties Window was replaced by the picture from imgDecca
on the other UserForm.

Hi Rick, Yes indeed, it works the same here too. But my logic is, if
the required label image doesn't exist it uses a default one. The way
I've coded it, the Form doesn't (have to) close and the last label it
loaded remains the active one. I could just copy it again but as it's
already there, why not use it? Trouble is, it's just called (Bitmap)
in properties and I don't know how to access it (apart from Close/Open
the form).

Thanks - Kirk
 
R

Rick Rothstein

Maybe I still am not following what you are trying to say, but you can
always reference an Image control's Picture property no matter how that
picture was loaded... if it was assigned from a file at design time, your
code can still get the picture by assigning its Picture property to whatever
other Image control you have (this can be done in the Workbook's Open event
if you need it before your code runs).
 
Top