: Does anybody know how to make the picture box use a picture from a web location?
:
:
Here is a reusable function you can use ...
Function LoadPictureBoxFromWeb(ByVal surface As PictureBox, ByVal url As String) As Boolean
If surface Is Nothing Then
Return False
End If
Try
Dim request As WebRequest = WebRequest.Create(url)
Dim response As WebResponse = request.GetResponse()
surface.SizeMode = PictureBoxSizeMode.AutoSize
surface.Image = Image.FromStream(response.GetResponseStream)
Catch
Return False
End Try
Return True
End Function
This assumes you have these namespaces imported ...
Imports System.Net
Imports System.Windows.Forms
You may or may not have import the System.Drawing namespace.
Using the function is easy ...
Dim url As String = "http://www.someaddress.com/image.jpg"
Call LoadPictureBoxFromWeb(PictureBox1, url)
Of course there is alot more room to make this more robust, but this should be a good starting point.