Results 1 to 7 of 7

Thread: Help with pics

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    60

    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.

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Help with pics

    imgPicture is an image Control?

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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:
    1. Dim imgPhoto as Image
    2.  
    3. Set imgPhoto = Me.Controls.Add("VB.Image", "imgPhoto")
    4. imgPhoto.Picture = LoadPicture("full path to your image")
    5. imgPhoto.Move 300, 300
    6. imgPhoto.Visible = True

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    60

    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.

  5. #5
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: Help with pics

    what is the control (picture box or image control) and what is its name?

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    60

    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.

  7. #7
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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
  •  



Click Here to Expand Forum to Full Width