IT.COM

Trouble getting code to work with visual basic

Spaceship Spaceship
Watch
Impact
56
I'm trying to create a visual basic program that will refresh a browser url in internet explorer after the page gets done loading. Here is my code:

Public Class Form1
Public Sub RefreshPage()

Dim page As New InternetExplorer
page.Navigate("www.google.com")
page.Visible = True
Do
Loop Until page.ReadyState = READYSTATE_COMPLETE
page.Refresh()

End Sub

End Class

When i try to build the application I get errors

Error 1 Type 'InternetExplorer' is not defined. C:\Users\Admin\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 4 25 WindowsApplication1
Error 2 'READYSTATE_COMPLETE' is not declared. It may be inaccessible due to its protection level. C:\Users\Admin\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb 8 38 WindowsApplication1

I referenced Microsoft Internet Controls so I don't know what i'm doing wrong?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
why not do it via simple cross-browser javascript?
in its simplest form it would be


Code:
<body onload="document.location.href='http://google.com'">


you can also add any kinds of fading or whatever effects/messages you want in between which would take you some 2-3 lines of code = who needs VBasic nowadays :)
 
0
•••
why not do it via simple cross-browser javascript?
in its simplest form it would be


Code:
<body onload="document.location.href='http://google.com'">


you can also add any kinds of fading or whatever effects/messages you want in between which would take you some 2-3 lines of code = who needs VBasic nowadays :)

Thanks for the quick reply! I don't know anything about javascript so how do I run this? I tried reading up on it and apparently you can run it from your browser. However, it does nothing when i paste this code into my browser window.
 
0
•••
However, it does nothing when i paste this code into my browser window.

that should go into your page html code - in fact it already has <body> tag (it should be there, if not - your code is seriously broken), just replace it with

<body onload="document.location.href='http://google.com'">

page would immediately redirect to google.com upon loading.. if you are not using long polling or comet of any flavor it will happen fast (not sure you meant to actually have this functionality), to make transition smooth/slow you'll need to add a couple of simple javascript snippets into the html thou

..i would strongly recommend reading a bit up on javascript before tweaking the source. i can assure you its much simpler than VB - you'll be ready to make great things in a couple of days.. and hey - for all browsers at once, not only for IE :)


PS: to test any JS string in a browser get Firefox with Firebug extension - you'll be able to test any js code on the fly...

---------- Post added at 05:40 PM ---------- Previous post was at 05:35 PM ----------

..oh did you mean you want external control - redirecting browser after any page load? if so, please disregard all i wrote - it'll only work with your own pages/site which html code is under your control and you can modify it

:)
 
0
•••
that should go into your page html code - in fact it already has <body> tag (it should be there, if not - your code is seriously broken), just replace it with

<body onload="document.location.href='http://google.com'">

page would immediately redirect to google.com upon loading.. if you are not using long polling or comet of any flavor it will happen fast (not sure you meant to actually have this functionality), to make transition smooth/slow you'll need to add a couple of simple javascript snippets into the html thou

..i would strongly recommend reading a bit up on javascript before tweaking the source. i can assure you its much simpler than VB - you'll be ready to make great things in a couple of days.. and hey - for all browsers at once, not only for IE :)


PS: to test any JS string in a browser get Firefox with Firebug extension - you'll be able to test any js code on the fly...

---------- Post added at 05:40 PM ---------- Previous post was at 05:35 PM ----------

..oh did you mean you want external control - redirecting browser after any page load? if so, please disregard all i wrote - it'll only work with your own pages/site which html code is under your control and you can modify it

:)

Oh yeah, the idea of all this was that my api can be refreshed as soon as it loads. My api only allows a request to be sent if the previous request has been processed. Otherwise it will result in a temporary ban from the api. So if I can find a way to get my script to detect that the page has loaded, it will go much quicker instead of having to let it reload the api at a given rate to avoid a temp ban (currently it just reloads every 1.75 seconds via a macro). My api speed varies in how long it takes to process, sometimes it can take 0.4 seconds and sometimes all the way up to 1.75 seconds.

API is what my registrar allows it's users to use to automate domain registration :)
 
Last edited:
0
•••
I don't know what i'm doing wrong?
Tried to do programming when it appears you do not know how to program.
Pay someone (hundreds list on freelancers.com)
 
0
•••
so you are calling the api directly and trying to "control" it via simple html ?

good luck with it
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back