Hack Forums
[.NET] Open .HTML file in WebBrowser1 (VISUAL BASIC 2008) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Open .HTML file in WebBrowser1 (VISUAL BASIC 2008) (/showthread.php?tid=25124)



Open .HTML file in WebBrowser1 (VISUAL BASIC 2008) - KvickaN - Aug 22, 2008

Hey I need help opening a .html file in the WebBrowser1...

Heres code:

Code
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        TextBox1.Text = OpenFileDialog1.FileName.ToString()
        WebBrowser1.Navigate("TextBox1.Contains")
        'Process.Start(OpenFileDialog1.FileName)I WANT THIS TO OPEN IN WebBrowser1
    End Sub

Please help!

This might help you too:
[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-1.jpg[/IMG]


- OXY - Aug 22, 2008

I notice your url has spaces in it. This is the problem. Remove the spaces and you'll be ok.


- KvickaN - Aug 22, 2008

OXY Wrote:I notice your url has spaces in it. This is the problem. Remove the spaces and you'll be ok.

I'll try that, gonna edit post soon.

edit:

No spaces in the .html file now but I gotta have it in "Program Files" cuz thats where the files ends up when installing the program. And if i can get that working it shouldnt be any problems having spaces in the .html files either.

New screen:
[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-2.jpg[/IMG]


- KvickaN - Aug 22, 2008

Tried this too but didnt work either, so it must be a problem with the code...

[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-3.jpg[/IMG]

I think it must be another solution with this:

WebBrowser1.Navigate("TextBox1.Contains")
'Process.Start(OpenFileDialog1.FileName)I WANT THIS TO OPEN IN WebBrowser1


- KvickaN - Aug 22, 2008

Here's a more explaining picture, hope you understand now =D

[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-4.jpg[/IMG]


- wohawsnng - Aug 22, 2008

Switch to Visual Basic 2005


- JapaBrz - Aug 22, 2008

this is not the right event.
the event to send the webbrowser1.navigate is in the button "open page" in command1_onclick()
so, put this in the onclick event of the commandbutton:
Code
OpenFileDialog1.ShowDialog()
        a = OpenFileDialog1.FileName
        If a <> vbNullString Then
            text1.text=a
            WebBrowser1.Navigate(a)
        End If
Remember: this is in the commandbutton click!
and about the spaces, i think the space is the name of the file, ill work but
is not recomended cuz if u create a site(maybe someday)
the name cant have spaces.

cya


- KvickaN - Aug 22, 2008

japabrz Wrote:this is not the right event.
the event to send the webbrowser1.navigate is in the button "open page" in command1_onclick()
so, put this in the onclick event of the commandbutton:
Code
OpenFileDialog1.ShowDialog()
        a = OpenFileDialog1.FileName
        If a <> vbNullString Then
            text1.text=a
            WebBrowser1.Navigate(a)
        End If
Remember: this is in the commandbutton click!
and about the spaces, i think the space is the name of the file, ill work but
is not recomended cuz if u create a site(maybe someday)
the name cant have spaces.

cya

That was genius!

Allthough the "a" gets an error... :(

Anyway to fix that?

See below:
[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-5.jpg[/IMG]

Error1 Name 'a' is not declared.


- JapaBrz - Aug 22, 2008

declare the A variable in the class of the form like:
Public Class Form1
Dim a As String

blablablabla

End Sub
End Class


- KvickaN - Aug 22, 2008

japabrz Wrote:declare the A variable in the class of the form like:
Public Class Form1
Dim a As String

blablablabla

End Sub
End Class

That solved it! Thanks alot man!

Much appriciated!


RE: Open .HTML file in WebBrowser1 (VISUAL BASIC 2008) - gigajew - Oct 23, 2017

If you show the source of the html, there's a chance you can make it way more efficient