ATTN: VBGOD and any other VB programmers... please help...

Discussion in 'OT Technology' started by Voland, Jan 14, 2004.

  1. Voland

    Voland AHHH MOTHERLAND!!!

    Joined:
    Jun 29, 2002
    Messages:
    11,290
    Likes Received:
    0
    Location:
    St Louis
    How do I change the picture of a PictureBox through Code? I used to know how to do this when I did VB6 years ago... I'm using .NET and I just can't seem to remember/find it.
     
  2. Voland

    Voland AHHH MOTHERLAND!!!

    Joined:
    Jun 29, 2002
    Messages:
    11,290
    Likes Received:
    0
    Location:
    St Louis
  3. VBGOD

    VBGOD Guest

    Oh, they've changed it. It used to be something like

    Code:
    MyPictureBox.Picture = LoadPicture("test.gif")
    Now it's

    Code:
    MyPictureBox.Image = Image.FromFile("test.gif")
    
    I'm about 99% sure of this. Double check to make certain. Also, you should see if the image actually exists before loading it.
     
  4. VBGOD

    VBGOD Guest

    The long way...

    Code:
            If System.IO.File.Exists("test.gif") = False Then
                'No no.. doesn't exist
            End If
    
    The proper way is as follows..

    Import the .NET library by typing this at the top of your class.
    Code:
    Imports System.IO
    Now you can refer to the file object just like this...

    Code:
            If File.Exists("test.gif") = False Then
                'No no.. doesn't exist
            End If
    
    There's literally so many goodies at your finger tips. I suggest your play around with this object.

    I have to go to sleep.

    :wavey:
     
  5. VBGOD

    VBGOD Guest

    Final bump.
     

Share This Page