Show image from URL in a PictureBox with

Here’s a small bit of code to download a image file from a URL, store it inside the RAM memory and then show it in a PictureBox.

This tiny bit of code worked in 2017. I have no idea if it will work in older or newer versions when they come. Just test it out.

Imports System.IO

Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Using c As New Net.WebClient
c.Headers.Add(“User-Agent”, “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063”)

‘Does the image work? Check the URL if you cant run the code.
Dim b = c.DownloadData(“”)
Using s As New MemoryStream(b)
Dim i = Image.FromStream(s)
PictureBox1.Image = i
End Using
End Using

End Sub
End Class

Leave a Reply

Your email address will not be published. Required fields are marked *