picture box from web location - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

picture box from web location

digitalgeekdigitalgeek Posts: 59Member
Does anybody know how to make the picture box use a picture from a web location?


  • iwilld0itiwilld0it Posts: 1,134Member
    : 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

    Dim request As WebRequest = WebRequest.Create(url)
    Dim response As WebResponse = request.GetResponse()

    surface.SizeMode = PictureBoxSizeMode.AutoSize
    surface.Image = Image.FromStream(response.GetResponseStream)
    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.

Sign In or Register to comment.