I need a Simple code for Image Load to Form VB6

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tomservo
    New Member
    • Mar 2007
    • 23

    I need a Simple code for Image Load to Form VB6

    Hi everybody.
    I Know there is a lot of information about this subject but it's quite indepth and I just need to know if there is a basic command for loading an image file to a pre-sized Image box (set to Stretch) from code, and then I can mess about with the Ifs & Then's and the For's & To's,...is there anything like this (which doesn't work straight off) :-

    Image1.Image = LoadImage("C:\I mage.bmp")
  • markmcgookin
    Recognized Expert Contributor
    • Dec 2006
    • 648

    #2
    Originally posted by Tomservo
    Hi everybody.
    I Know there is a lot of information about this subject but it's quite indepth and I just need to know if there is a basic command for loading an image file to a pre-sized Image box (set to Stretch) from code, and then I can mess about with the Ifs & Then's and the For's & To's,...is there anything like this (which doesn't work straight off) :-

    Image1.Image = LoadImage("C:\I mage.bmp")
    Hey yeah, I think I have code for this, but i can't give it right now, i'm in uni and dont have access to it here. I should be able to post it when I get home which will be a maximum of 7 hours. (5.30pm GMT)

    Comment

    • markmcgookin
      Recognized Expert Contributor
      • Dec 2006
      • 648

      #3
      Originally posted by markmcgookin
      Hey yeah, I think I have code for this, but i can't give it right now, i'm in uni and dont have access to it here. I should be able to post it when I get home which will be a maximum of 7 hours. (5.30pm GMT)

      Never mind... found it

      Code:
      Imports System.Drawing
      
      Dim MyImage As Bitmap  ' Image to import into Picturebox
      
      *** Method ***
      
      Public Sub ShowPic(ByVal fileToDisplay As String)
      
              ' Set the SizeMode property to Stretch
              Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
      
              If Not (MyImage Is Nothing) Then
                  MyImage.Dispose()
              End If
      
              MyImage = New Bitmap(fileToDisplay)
              PictureBox1.Image = CType(MyImage, Image)
              PictureBox1.Show()
      
          End Sub
      
      *** Calling i.e. This bit on the button event ***
      
      LoadDescription()
              ImageLoc = "my documents\pictures\" & IdSEL & ".jpg"
              ShowPic(ImageLoc)
      
      *** End ***
      
      Obviously bits will need changed (filepaths etc.) but you should get an idea of what is needed.

      Comment

      • Tomservo
        New Member
        • Mar 2007
        • 23

        #4
        Originally posted by markmcgookin
        Never mind... found it

        Code:
        Imports System.Drawing
        
        Dim MyImage As Bitmap  ' Image to import into Picturebox
        
        *** Method ***
        
        Public Sub ShowPic(ByVal fileToDisplay As String)
        
                ' Set the SizeMode property to Stretch
                Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        
                If Not (MyImage Is Nothing) Then
                    MyImage.Dispose()
                End If
        
                MyImage = New Bitmap(fileToDisplay)
                PictureBox1.Image = CType(MyImage, Image)
                PictureBox1.Show()
        
            End Sub
        
        *** Calling i.e. This bit on the button event ***
        
        LoadDescription()
                ImageLoc = "my documents\pictures\" & IdSEL & ".jpg"
                ShowPic(ImageLoc)
        
        *** End ***
        
        Obviously bits will need changed (filepaths etc.) but you should get an idea of what is needed.
        Thanks a lot MarkMcgookin I'll give it a go.

        Comment

        Working...