Favicon help?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions 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.
24 posts Page 3 of 3
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Favicon help?
Codex
The reason it's not working is because your Gecko browser has about:blank as the url, which is not a valid one.

Try replacing the code with this:
Code: Select all
If Regex.IsMatch(Geckobrowser1.url.tostring, "(https?ftp):\/\/([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})(:\d{1,4})?([-\w\/#~:.?+=&%@~]*)/") Then 
Dim iconURL = Geckobrowser1.Url.ToString & "/favicon.ico"
        Dim request As System.Net.WebRequest = System.Net.HttpWebRequest.Create(iconURL)
        Dim response As System.Net.HttpWebResponse = request.GetResponse()
        Dim stream As System.IO.Stream = response.GetResponseStream()
        Dim iconimage As Bitmap = Image.FromStream(stream)
        Me.Icon = Icon.FromHandle(iconimage.GetHicon())
End if
I haven't tested it, but it should work.
And you need to import System.Text.RegularExpressions at the top.
(Imports System.Text.RegularExpressions)
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Favicon help?
MrAksel
Did you write that regex yourself? I can spot some errors :)
My best shot is:
Code: Select all
"((http|https|ftp):\/\/)?[0-9a-zA-Z\-_]{1,63}\.([0-9a-zA-Z\-_]{1,63}\.){1,123}[0-9a-zA-Z\-_]{1,63}([:\d]{1,5})?[\/]?([\w\.-][\/]?)*
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
dj1437
VIP - Donator
VIP - Donator
Posts: 504
Joined: Tue Dec 21, 2010 2:02 am

Re: Favicon help?
dj1437
The code fails, it says too many )'s
This is a signature.
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Favicon help?
MrAksel
Was that my regex? Codex's has errors so that won't work. I have tested mine on multiple URLs and it matches all correctly. Just now I counted the ( and )'s, and there is an equal amount so that shouldn't be an error.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
24 posts Page 3 of 3
Return to “Coding Help & Support”