program detects picture box error/
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
how can i make it show a message box if the picture box image does not load
example a user inputs
a url like tis
example.com/img.jpg
but thats not a real link so it brings up the boxed 'X'
how can i do it?
example a user inputs
a url like tis
example.com/img.jpg
but thats not a real link so it brings up the boxed 'X'
how can i do it?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

Code: Select all
Dim data As Byte()
Dim wc As WebClient = New WebClient()
Try
data = wc.DownloadData("http://localhost/image.png")
Catch ex As Exception
MsgBox("error: " & ex.Message)
Return
End Try
Dim ms As MemoryStream = New MemoryStream(data, 0, data.Length, False, True)
Try
PictureBox1.Image = Image.FromStream(ms)
Catch ex As Exception
MsgBox("error: " & ex.Message)
End Try
ms.Close()
i mean if its a broken url it doesnt show it
so like a working is this
www.example.com/pic.png
and a broken is this
www.example.com/plc.png
the broken will not show but if the working is typed in no message box will popup
so like a working is this
www.example.com/pic.png
and a broken is this
www.example.com/plc.png
the broken will not show but if the working is typed in no message box will popup
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

Those links are both valid, if the image is not found the webclient will return an error.
if the picture works the thing will still show it though
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023