Picturebox question

himey

New member
Joined
Jan 28, 2003
Messages
2
How can I populate a Picturebox control with an image from a known location on the internet with VB .NET?

For example, if I click a button and wanted to populate the Picturebox control with the Extreme .NET Forums logo from the top of this page, I would want the code to go out and load the image that can be found at http://www.computerhelp.forum/images/logo.gif

Can someone show me a blurb of code that would do this?

Thanks,

Himey
 
Assuming you have a picturebox on your form called PictureBox1...

Code:
        Dim wc As New System.Net.WebClient()
        Dim bdata() As Byte
        Dim ms As MemoryStream

        bdata = wc.DownloadData("http://www.computerhelp.forum/images/logo.gif")
        ms = New MemoryStream(bdata)

        PictureBox1.Image = Bitmap.FromStream(ms)
 
Excellent advice. Works perfectly. Thank you very much.

I figured it had to do with streams, but I hadnt checked the memory stream.
 
Back
Top