Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Open .HTML file in WebBrowser1 (VISUAL BASIC 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]
I notice your url has spaces in it. This is the problem. Remove the spaces and you'll be ok.
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]
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
Here's a more explaining picture, hope you understand now =D

[IMG]http://i270.photobucket.com/albums/jj97/KvickaN89/untitled-4.jpg[/IMG]
Switch to Visual Basic 2005
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
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.
declare the A variable in the class of the form like:
Public Class Form1
Dim a As String

blablablabla

End Sub
End Class
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!


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersNov 11, 2025 09:42 AM 0 205 Nov 11, 2025 09:42 AM
Last Post: Hackers
[Source] by SIM-5420967May 26, 2024 09:50 AM 2 371 May 26, 2024 09:50 AM
Last Post: xiaowanga8
[.NET] by VisualSoftFeb 5, 2024 02:18 AM 13 1,027 Feb 5, 2024 02:18 AM
Last Post: riddickval