View Full Version : Visual basic: making a html file appear in a window

12-20-2004, 11:13 PM
Hey guys. i was wondering if anyone knew how I could make a sort of I Frame and make a html file, that is stored localy, apper in this window.

Any help please

thanks guys. ;) :thumbsup:

12-20-2004, 11:40 PM
yup its some sort or control, like web browser or something and you just set the url of it.


12-21-2004, 08:36 AM
do u mean say... u want to embed html to your Visual Basic form... if thats the one, i can help.

12-21-2004, 09:50 AM
Yes, it's the WebBrowser control. Here's an example. (http://www.a1vbcode.com/app.asp?ID=2579)


12-21-2004, 02:22 PM
ok guys thanks a lot, i got it to work. Now I have one more problem.

As i is loading a html file from the local machine, i have to provide a link to the file. Currently im useing this.

Private Sub Form_Load()
WebBrowser1.Navigate "C:\index.htm"
End Sub

but this means that the html file has to be in c:\ and i dont want that, i want it to be in the same directory as the .exe file. I have tried changeing it to

WebBrowser1.Navigate "index.htm"

WebBrowser1.Navigate "\index.htm"

but have no luck. Do you guys know of a way I can get around this?

Thanks for your time. :thumbsup:

12-21-2004, 02:44 PM
combine the results of App.Path (http://whidbey.msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbpropath.asp) with your filename

12-21-2004, 04:37 PM
but thats the problem, im not going to know the path of where the files are going to be stored. I can get it to work, but with a set path. I dont want a set path, i want the two files to be able to get put in the same folder anywhere on the computer and the programme will run.

thanks for your help. ;)

12-21-2004, 05:52 PM
App.Path will evaluate to the folder containing the exe at runtime. So as long as the files are in the same folder as the exe (or a specific subfolder if you include that with the filename), it will work no matter where the application is installed.


12-21-2004, 08:48 PM
ah, ok, i understand.

So how would i go about useing this. Iv taken a look at that link and its a little confuesing to me, lol.

Am new to VB ;)

12-22-2004, 12:56 AM
its something like

WebBrowser1.Navigate App.Path & "\myfile.htm"

you may need to remove the slash before myfile.htm

In VB you can combine all sorts like tha, i think the best thing is when you type a control name and then press the . button and get a full list of options.

The otherthing is looking at alternative names for stuff e.g. functions/options/cases/properties for one of a better word, as it really helped me as a web developer to sort of get my head round VB.


12-22-2004, 01:33 AM
Ha, had a little play around with that app.path thing and it wouldnt work, so i tried setting it as a variable first then loading it and finaly got it to work. :D thanks for your helo mate ;)

this is what i used:

Private Sub Form_Load()
Dim loc As String
loc = App.Path & "\" & "Index.htm"
WebBrowser1.Navigate loc
End Sub

12-22-2004, 07:36 PM
you can use to brackets to enclose stuff, as it can get round stuff that combines things together, just like you do in maths.

if you mix numbers and strings, you have to use str(expression) so it makes it all to a string.

so i think you could rewrite it on msn as

Private Sub Form_Load()

WebBrowser1.Navigate (App.Path & "\" & "Index.htm")
End Sub

if you want add me on msn mattienewt@hotmail.com as i'm doing some vb stuff so i might be able to help you a bit as i'm in a similair boat as you.


12-23-2004, 09:20 AM
If Navigate is a Sub and not a function (which I think is the case), then in order to use brackets you would need the Call keyword:

Call WebBrowser1.Navigate (App.Path & "\" & "Index.htm")

or else the compiler will complain (one of those nice little VB quirks)