Retrieving an Image from the Web

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello, Im looking to retrieve an image from any website and to show that image in a form. The user is to type the web address into a text box then click a button, then the program should fetch the first image on that web page and display that image in a picture box or something in a form. Im having some trouble doing it, this is the code I have which doesnt work but I think is close, can someone point me in the right direction please? Thanks
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim MyWebClient As New System.Net.WebClient
Dim ImageInBytes() As Byte = MyWebClient.DownloadData(TextBox1.Text)
Dim ImageStream As New IO.MemoryStream(ImageInBytes)

PictureBox1.Image = New System.Drawing.Bitmap(ImageStream)
End Sub

View the full article
 
Back
Top