Results 1 to 6 of 6

Thread: [RESOLVED] LoadPicture issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2017
    Posts
    498

    Resolved [RESOLVED] LoadPicture issue

    How do I load a bitmap file into a picturebox?

    I thought I could do it using VB's LoadPicture like this

    Picture1.Picture = LoadPicture(App.Path & "\MyPicture.bmp") but I get a Type Mismatch error and the & is highlighted.

    and if I use the CommonDialogue to open the file and I use

    Picture1.Picture = LoadPicture(.FileName) I also get a Type Mismatch error

    If I put the entire path in a variable....

    Dim PictureFilePath As String

    Picture1.Picture = LoadPicture(PictureFilePath) I get a ByRef argument type mismatch

  2. #2
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: LoadPicture issue

    Add "Set".

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2017
    Posts
    498

    Re: LoadPicture issue

    Set Picture1.Picture = LoadPicture(...)

    doesn't change any of the errors

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2017
    Posts
    498

    Re: LoadPicture issue

    OK, never mind, I found the reason

    I had a copy of the code from the user control placed in a .bas module. I was just saving it there for some reason that I have now forgot about. When I removed the module the LoadPicture worked

  5. #5
    Fanatic Member
    Join Date
    Feb 2019
    Posts
    706

    Re: [RESOLVED] LoadPicture issue

    Search your code for "LoadPicture". If you defined a Sub/function with that name, then VB would use it instead.

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,186

    Re: [RESOLVED] LoadPicture issue

    You can also use VB.LoadPicture() instead of defaulting to the global namespace.

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