Results 1 to 5 of 5

Thread: Loading Images[solved]

  1. #1

    Thread Starter
    Addicted Member vigge89's Avatar
    Join Date
    May 2002
    Location
    Sweden
    Posts
    172

    Loading Images[solved]

    Is it possible to load an image (with LoadPicture()) into an variable?

    I need to preload some images before i use them, and using an ImageList seems kinda komplex, so i'm wondering if you can load images into variables in runtime, or something like that.

    Thanks in advance
    Last edited by vigge89; May 4th, 2004 at 08:51 AM.


  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    Well this seems to work:

    VB Code:
    1. Dim tmpImg As IPictureDisp
    2.  
    3. 'to put a picture in a variable
    4. Set tmpImg = LoadPicture("c:\thisimage.jpg")
    5.  
    6. ..
    7. ..
    8. ..
    9.  
    10. 'then - to put the picture in an Image control
    11. Image1.Picture = tmpImg
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    Fanatic Member ahara's Avatar
    Join Date
    Nov 2003
    Location
    Toronto
    Posts
    531
    you could use a resource file to store the images....there should be some examples in this forum if you do a search...if not, post back and I will provide one. cheers
    "Knowledge is gained when different people look at the same information in different ways"

    - Louis Pasteur

  4. #4

    Thread Starter
    Addicted Member vigge89's Avatar
    Join Date
    May 2002
    Location
    Sweden
    Posts
    172
    hmm, i have declared the variable in one of my forms (frmMain), as an Public variable (Public var as Type), but when i do this:
    VB Code:
    1. frmMain.img_btn_normal = LoadPicture(btn_normal)
    2.     frmMain.img_btn_down = LoadPicture(btn_down)

    I get runtime error 91: "Object variable or With block variable not set"

    Why doesn't it work?


  5. #5

    Thread Starter
    Addicted Member vigge89's Avatar
    Join Date
    May 2002
    Location
    Sweden
    Posts
    172
    Forgot the SET
    Solved, thanks!


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