VB.net help with images

I need programming help with my vb.net project.  I want some images to be in the project resource file, and put the images on various controls.   I can do this successfully by reading the images I want from a file, but that creates installation overhead for the app.  I need to know how to put the images into the project, apart from any files.
Brian ConcannonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You simply add them to the Project 'Resources' Page -Capture.PNGOr set the 'Build Action' property of the file to 'Embedded Resource' -Capture.PNG
In either case, I like to keep my embedded resources in a folder contained within the project (usually named Resources).  Once they are embedded you can access them using the resource manager (for items on the Project 'Resources' Page) or reflection (for resources that are marked as 'Embedded Resources'); e.g. -

Form1.vb -
Imports System.IO
Imports System.Reflection

Public Class Form1
	Private Sub OnLoad(sender As Object, e As EventArgs) Handles MyBase.Load
		PictureBox1.Image = My.Resources.HIMTBook
		PictureBox2.Image = GetResourceImage("EE_Q29085749.HIMTBook.JPG")
	End Sub

	Function GetResourceImage(name As String) As Image
		Dim result As Image
		Dim [assembly] As Assembly = Assembly.GetExecutingAssembly()
		Using [stream] As Stream = assembly.GetManifestResourceStream(name)
			result = New Bitmap(stream)
		End Using
		Return result
	End Function
End Class

Open in new window

Form1.Designer.vb -
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
	Inherits System.Windows.Forms.Form

	'Form overrides dispose to clean up the component list.
	<System.Diagnostics.DebuggerNonUserCode()> _
	Protected Overrides Sub Dispose(ByVal disposing As Boolean)
			If disposing AndAlso components IsNot Nothing Then
			End If
		End Try
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	<System.Diagnostics.DebuggerStepThrough()> _
	Private Sub InitializeComponent()
		Me.PictureBox1 = New System.Windows.Forms.PictureBox()
		Me.PictureBox2 = New System.Windows.Forms.PictureBox()
		CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
		CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.PictureBox1.Dock = System.Windows.Forms.DockStyle.Left
		Me.PictureBox1.Location = New System.Drawing.Point(0, 0)
		Me.PictureBox1.Name = "PictureBox1"
		Me.PictureBox1.Size = New System.Drawing.Size(340, 510)
		Me.PictureBox1.TabIndex = 0
		Me.PictureBox1.TabStop = False
		Me.PictureBox2.Dock = System.Windows.Forms.DockStyle.Right
		Me.PictureBox2.Location = New System.Drawing.Point(344, 0)
		Me.PictureBox2.Name = "PictureBox2"
		Me.PictureBox2.Size = New System.Drawing.Size(340, 510)
		Me.PictureBox2.TabIndex = 1
		Me.PictureBox2.TabStop = False
		Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
		Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
		Me.ClientSize = New System.Drawing.Size(684, 510)
		Me.Name = "Form1"
		Me.Text = "Form1"
		CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
		CType(Me.PictureBox2, System.ComponentModel.ISupportInitialize).EndInit()

	End Sub

	Friend WithEvents PictureBox1 As PictureBox
	Friend WithEvents PictureBox2 As PictureBox
End Class

Open in new window

Which produces the following output -Capture.PNG

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
richard reesCommented:
tried id, still a bug, see att.
richard reesCommented:
how do I upload 3 files?  will try one at a time.IMG PROPSOK 3RD FILE NOW
I obviously have difficulty showing multiple screenshots.

Can I get a teamviewer session from you?  I will pay.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

How did you mark your resource?  Did you add it through the project resources page or mark it as an Embedded resource?

You can always determine the resource name by simply iterating over the GetManifestResourceNames collection; e.g. -
	Private Sub OnLoad(sender As Object, e As EventArgs) Handles MyBase.Load
		For Each item In Assembly.GetExecutingAssembly().GetManifestResourceNames()
	End Sub

Open in new window

Which would produce the following output -Capture.PNG-saige-
richard reesCommented:
Screen capture

I tried it and have a null stream error.  I have screenshots for you and would like more help. How should I proceed?
richard reesCommented:
IT_SAIGE SEE PIC.  i still do not know how to converse with you, this way seems cumbersome.  Null stream error even with verified name.

Screenshot verifying the resource name
richard reesCommented:
Solution accepted thank you
Solution accepted by user
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.