First, I see that the image src
URL is a relative URL. That means you need to make it an absolute by doing something like this:
Dim absoluteURL As String = "domain of captcha" & captchaURL
Then, you need to download the image into Bytes by doing something like this:
Dim PictureBytes As Byte()
' Convert String to a Uri
Dim address As New Uri(absoluteURL, UriKind.Absolute)
' Create the web request
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(address), HttpWebRequest)
' Set type to GET
request.Method = "GET"
Try
' Get response
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
Dim stream As Stream = response.GetResponseStream
Dim reader New BinaryReader(stream)
PictureBytes = reader.ReadBytes(stream.Length)
Finally
If Not response Is Nothing Then response.Close()
End Try
Finally, you will need to convert the bytes to a bitmap and put that bitmap in a picture box
Dim Captcha As New Bitmap(new MemoryStream(PictureBytes));
pictureBox.Image = Captcha
If you encounter any problems, just comment on this post. If this code works, please consider marking this correct and up-voting. Please note, up-voting or marking an answer correct DOES NOT subtract reputation.