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

Extract URLs from HTML with

Extract URLs from HTML with In this example the HTML is in TextBox1 and it will store the URLs in a listbox named URLsResult.

Dim strReg As String
Dim RunShit As String
strReg = ".*?)[""'].*?>(?.*?)"
Dim reg As New Regex(strReg, RegexOptions.IgnoreCase)
Dim m As Match = reg.Match(TextBox1.Text)

While m.Success
RunShit = m.Groups(1).Value
If RunShit.Substring(0, 4) = "http" Then
URLsResult.Items.Add(RunShit) '
End If
m = m.NextMatch()
End While

Download HTML-source with

Paste in a module and just call the function like this:
HelloString = GetHTML(“”)

Private requestweb As HttpWebRequest
Private responseWeb As HttpWebResponse

Public Function GetHTML(ByVal URL)
Dim WebSource As String = ""
Dim objStreamReader As StreamReader = Nothing

requestweb = CType(WebRequest.Create(URL), HttpWebRequest)
With requestweb
.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
.Method = "GET"
.Timeout = 10000
End With

responseWeb = CType(requestweb.GetResponse(), HttpWebResponse)
Catch ex As Exception
MessageBox.Show("Error retrieving the Web page " & _
"you requested. Please check the entered Url and your internet connection")
Exit Function
End Try

If Not IsNothing(responseWeb.GetResponseStream()) Then
'objStreamReader = New StreamReader(responseWeb.GetResponseStream())
objStreamReader = New StreamReader(responseWeb.GetResponseStream(), Encoding.UTF8)
WebSource = objStreamReader.ReadToEnd
Catch ex As Exception
Exit Function
End Try

End If
Return (WebSource)
End Function