01-20-2012، 12:46 PM
Load image from URL into PictureBox
This is a snippet to load an image from a URL into a PictureBox on a Windows form
کد پیاچپی:
Instructions: Need reference to:
System.Net
System.Drawing
سورس کد
کد پیاچپی:
Public Sub LoadImageFromUrl(ByRef url As String, ByVal pb As PictureBox)
Dim request As Net.HttpWebRequest = DirectCast(Net.HttpWebRequest.Create(url), Net.HttpWebRequest)
Dim response As Net.HttpWebResponse = DirectCast(request.GetResponse, Net.HttpWebResponse)
Dim img As Image = Image.FromStream(response.GetResponseStream())
response.Close()
pb.SizeMode = PictureBoxSizeMode.StretchImage
pb.Image = img
End Sub