By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,096 Members | 1,355 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,096 IT Pros & Developers. It's quick & easy.

I need a Simple code for Image Load to Form VB6

P: 23
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:\Image.bmp")
Mar 16 '07 #1
Share this Question
Share on Google+
3 Replies


markmcgookin
Expert 100+
P: 648
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:\Image.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)
Mar 16 '07 #2

markmcgookin
Expert 100+
P: 648
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

Expand|Select|Wrap|Line Numbers
  1. Imports System.Drawing
  2.  
  3. Dim MyImage As Bitmap  ' Image to import into Picturebox
  4.  
  5. *** Method ***
  6.  
  7. Public Sub ShowPic(ByVal fileToDisplay As String)
  8.  
  9.         ' Set the SizeMode property to Stretch
  10.         Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
  11.  
  12.         If Not (MyImage Is Nothing) Then
  13.             MyImage.Dispose()
  14.         End If
  15.  
  16.         MyImage = New Bitmap(fileToDisplay)
  17.         PictureBox1.Image = CType(MyImage, Image)
  18.         PictureBox1.Show()
  19.  
  20.     End Sub
  21.  
  22. *** Calling i.e. This bit on the button event ***
  23.  
  24. LoadDescription()
  25.         ImageLoc = "my documents\pictures\" & IdSEL & ".jpg"
  26.         ShowPic(ImageLoc)
  27.  
  28. *** End ***
  29.  
  30. Obviously bits will need changed (filepaths etc.) but you should get an idea of what is needed.
  31.  
  32.  
Mar 16 '07 #3

P: 23
Never mind... found it

Expand|Select|Wrap|Line Numbers
  1. Imports System.Drawing
  2.  
  3. Dim MyImage As Bitmap  ' Image to import into Picturebox
  4.  
  5. *** Method ***
  6.  
  7. Public Sub ShowPic(ByVal fileToDisplay As String)
  8.  
  9.         ' Set the SizeMode property to Stretch
  10.         Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
  11.  
  12.         If Not (MyImage Is Nothing) Then
  13.             MyImage.Dispose()
  14.         End If
  15.  
  16.         MyImage = New Bitmap(fileToDisplay)
  17.         PictureBox1.Image = CType(MyImage, Image)
  18.         PictureBox1.Show()
  19.  
  20.     End Sub
  21.  
  22. *** Calling i.e. This bit on the button event ***
  23.  
  24. LoadDescription()
  25.         ImageLoc = "my documents\pictures\" & IdSEL & ".jpg"
  26.         ShowPic(ImageLoc)
  27.  
  28. *** End ***
  29.  
  30. Obviously bits will need changed (filepaths etc.) but you should get an idea of what is needed.
  31.  
  32.  
Thanks a lot MarkMcgookin I'll give it a go.
Mar 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.