Results 1 to 7 of 7

Thread: Picture Box Variable Usage?? *Answered*

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Florida
    Posts
    98

    Picture Box Variable Usage?? *Answered*

    Morning ladies, gentlemen, small children, pets and UDP packets.

    I have been looking around for a few days and still unable to find the meaning to life. Maybe i have been asking the wrong question but who knows. If someone could answer it for me, I would greatly appreciate it and be able to live in a state of ahh knowing such knowledge

    Mostly i am wondering about using a variable declared as a picturebox variable. I was wondering if its possible to declare said variable and not use an actual picture box item to work with the picture?

    For Example:



    VB Code:
    1. Dim Picture1Temp As PictureBox
    2.     Dim picture2Temp As PictureBox
    3.    
    4.     picture2Temp.Picture = LoadPicture(sDir & sFileName)

    the above code doesn't quite work when you go to load the picture you get the error . .

    Number: 91

    Object variable or with block variable not set.

    Now i know i am just overlooking something obvious, i don't normally work with graphics much and have been running a fever for 2 days, so needless to say, ye old brain is taking a vacation without me. Thanks much in advance for any assistance.
    Last edited by TheVoid; Sep 13th, 2002 at 07:59 AM.

  2. #2
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    You must SET your object variable to an object first - until that it's just an object variable.

    Set picture2Temp = Me.Controls.Ad("VB.Picturebox", "Picture1")
    picture2Temp .Move 0, 0
    picture2Temp .Visible = True

    Also you may declare it as follows:
    Dim WithEvents picture2Temp As PictureBox

    Roy

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    N/M this post... IROY got in b4 me....

    The short answer is "no"
    The slightly longer answer is .. it doesn't work (as is) because all you have done is declare a variable of TYPE PictureBox... the PictureBox doesn't actualy exist tho...
    The even longer answer is.... there is a way to dynamicaly load controls at run time (two ways that I am aware of). Either way would allow you to create the pic box and then load into it. Search http://msdn.microsoft.com for Adding Controls at Runtime.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    yup.. so what IROY55 is saying is that you need at least one control on your form... just don't set it to visible if you don't want to see it...

    and there are no UDP packets here

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Florida
    Posts
    98
    Ahhhh!!!

    Thanks much for all the information

    We currently had a program that took a file, rotated it and turned the image to black and white using a Dll file. However that DLL turns out to create a nice little memory leak.

    So instead I load a picture into a picture box, rotate it and change ech pixel to Black and white and put those pixels in the next picture box.

    Was mostly trying to figure out a way to do this without actually having the form open with picture boxes out and such. IE in the background so the user can go about their business doing whatever users do when users sit in front of computers

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    Originally posted by TheVoid

    Was mostly trying to figure out a way to do this without actually having the form open with picture boxes out and such. IE in the background so the user can go about their business doing whatever users do when users sit in front of computers
    the form does not have to be visible either

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Location
    Florida
    Posts
    98
    Thanks everyone for the input although if you remember your always supposed to give the answer we want to hear

    Ended up putting two picture boxes on the form, and moving them basically off the form and out of view, then let them do their thing.

    Thanks again for all the quick responses.



    Dust and ashes my friends DUST! and ashes!

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