|
-
Feb 25th, 2006, 10:01 PM
#1
Thread Starter
Member
Help with pics
I've created an image window in a form and I'm trying to display a jpeg file in it. First of all, although I have tried, is "DIM imgPhoto as Image" necessary? The line command is as follows:
imgPicture.Picture = LoadPicture("C:\Documents and Settings\Owner\My Documents\My Pictures\DCAO0082.JPG")
Debug tells me that:
imgPicture.Picture =<Object variable or With Block variable not set>
I don't know what that means? What is an object variable/With block variable? The width property has a value.
-
Feb 25th, 2006, 10:05 PM
#2
Re: Help with pics
imgPicture is an image Control?
-
Feb 25th, 2006, 10:09 PM
#3
Re: Help with pics
Why not simply add Image control (or Picturebox) directly to your form in design? and then assign picture property at run time:
Image1.Picture = LoadPicture(...)
Anyway, if you prefer to create control at run time then just declaring object isn't enough - you'll have to set it by adding control to controls collection, posiotion it and then display it:
VB Code:
Dim imgPhoto as Image
Set imgPhoto = Me.Controls.Add("VB.Image", "imgPhoto")
imgPhoto.Picture = LoadPicture("full path to your image")
imgPhoto.Move 300, 300
imgPhoto.Visible = True
-
Feb 25th, 2006, 11:22 PM
#4
Thread Starter
Member
Re: Help with pics
Being new at this, I must have mixed up my nominclature. I do have a control box in the form. I just can't seem to put the picture in the box using the above command during run time.
-
Feb 25th, 2006, 11:27 PM
#5
Re: Help with pics
what is the control (picture box or image control) and what is its name?
-
Feb 26th, 2006, 08:59 AM
#6
Thread Starter
Member
Re: Help with pics
It is an image control, and the name is "imgPicture". Since starting this thread I went back and used the Picture Box tool, and it worked. As a beginner, I still would like to know why the Image control didn't work, and what the difference between the two are. Sam's doesn't do a good job at that.
-
Feb 26th, 2006, 05:54 PM
#7
Re: Help with pics
The Image control should work also.
The picture box has more functions than the image control but uses more of your resources.
The Image control is a light weight control like a label. It exsist on a graphics plane between the form background and the "heavy" controls such as the picturebox.
The image control also has a stretch property which allows you to choose whether the control will resize to fit the picture or the picture will resize to fit the control.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|