Hello everyone, :wave:
I am new to this forum as well as VB coding. I was wondering if someone was able to help me.
I made a web browers, but how can i make it load up a default url when i load the program?
Thank you for your time.
:)
Printable View
Hello everyone, :wave:
I am new to this forum as well as VB coding. I was wondering if someone was able to help me.
I made a web browers, but how can i make it load up a default url when i load the program?
Thank you for your time.
:)
How have you made the web browser, what control are you using?
i just got the instructions from here, im not too sure about the vb terms. im sorry im making you goto a url
http://www.voxcommunications.com/sky/vb_webbrowser.htm
I'm not at a computer with VB at the moment so i havn't tested this, but try putting this code in your forms Load event:
WebBrowser1.Navigate ("www.MyDefaultPage.com")
Thank you so much, SLH!
I tryed that code on all the wrong places, but did not think to do it on the form it self
:P
thanks again
:wave:
one more question.. . is there a way to make a timer load a url from the browser?
:confused:
Add the URL to a Timer control
Thanks for the link, always like extra tutorials on how to do stuff :DQuote:
Originally posted by Julie_Luvs
i just got the instructions from here, im not too sure about the vb terms. im sorry im making you goto a url
http://www.voxcommunications.com/sky/vb_webbrowser.htm
Hi, Insane_Magician, thats just a site from school ;)
------------------------
Hi BrianS, :wave:
how do i add a url to a time controler?
im rather new at vb.
or does anyone else know how to?
I'm not too sure what you want to do.
Do you want to load a specific web page after a given time, say every 5 minutes?
thats correct
:)
Add a timer control to your form (from the control toolbox), give it an appropriate interval (in seconds), the put the code i gave above into the timer's "Timer" event.
Actually, it's in milliseconds (thousandths of a second) ;). Remember, though, that the maximum interval is 65535 milliseconds (1.09225 minutes). If you want the interval to be over that, you'll need to use some tricks. Otherwise, the timer is fine as it is.
Oops!! :o
If you do need an interval longer than that take a look at the SetTimer API, or have a counter variable in a timer with an interval of a minute.
i just need it to be 5 mins, but what do i do from here?
:confused:
---------------------------------------------------------
Private Sub Timer1_Timer()
WebBrowser1.Navigate ("www.MyDefaultPage.com")
End Sub
You could set X=0 then have the timer go for 1000 and every time make x = x + 1 and when it gets to 5 load the page.
Did you mean this:
VB Code:
Private Sub Form_Load() WebBrowser1.Navigate ("http://google.com") Timer1.Interval = 10000 '2 second Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Static iCounter As Integer iCounter = iCounter + 1 If iCounter = 6 Then frmBrowser.Show WebBrowser1.Navigate ("http://yahoo.com") iCounter = 0 'With your other code and this, every minute the navigate will fire 'With this line commented out, it will only happen once End If End Sub
Really? It works fine for me. Could you post your project?
oops im sorry it does load, did not know it takes a min.
i thought it loads every 2 seconds.
but the problem is yahoo.com is still refreshing and not stoping
is there something i did wrong?
Code:Private Sub Form_Load()
WebBrowser1.Navigate ("http://google.com")
Timer1.Interval = 10000 '2 second
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static iCounter As Integer
iCounter = iCounter + 1
If iCounter = 6 Then
frmBrowser.Show
WebBrowser1.Navigate ("http://yahoo.com")
iCounter = 0 'With your other code and this, every minute the navigate will fire
'With this line commented out, it will only happen once
End If
End Sub
Comment out the line iCounter = 0 to make it only go to Yahoo once (after 1 minute). The interval multiplied by the control expression's constant in that if (6) is how long it will wait. In this case, it's 10,000 milliseconds times 6 = 60,000 milliseconds = 60 seconds = 1 minute. One other thing you might want to do if it only loads once is to disable the timer after you're done with it.
im not too sure how to do this. may you please give me an example on how to stop timer?
:blush:
On how to make it only navigate to Yahoo 1 time after 1 minute:
VB Code:
Private Sub Form_Load() WebBrowser1.Navigate ("http://google.com") Timer1.Interval = 10000 '2 second Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Static iCounter As Integer iCounter = iCounter + 1 If iCounter = 6 Then frmBrowser.Show WebBrowser1.Navigate ("http://yahoo.com") Timer1.Enabled = False End If End Sub
I hope I've answered what you asked. If not, just elaborate and I'll do it again ;)
it works!!
Thank you so much, you were a great help!
:)
ok now i got another question, how can i make it load a third URL?
Something like.....
VB Code:
Private Sub Form_Load() WebBrowser1.Navigate ("http://google.com") Timer1.Interval = 10000 '2 second Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Static iCounter As Integer iCounter = iCounter + 1 If iCounter = 6 Then frmBrowser.Show WebBrowser1.Navigate ("http://yahoo.com") End If If iCounter = 12 Then frmBrowser.Show WebBrowser1.Navigate ("http://cnn.com") Timer1.Enabled = False End If End Sub
This'll originally go to Google, then, after 1 minute, Yahoo, and then, after another minute, CNN.com.
how many seconds is:
Timer1.Interval = 10000
:confused:
10.
The Interval property is in milliseconds which are thousandths of a second. Therefore, 1000 ms (abbreviation for milliseconds) = 1 second. 10 seconds = 10,000 ms.
ahhh i get it now, i was so confused before
lol
my math is really bad, please help
:blush:
360000 ms = 6 min
?
Yes. Doing it in steps: 6 minutes = 6*60 seconds = 360 seconds. 360 seconds = 360 * 1000 ms = 360000.
is there a way i can load up a .txt file of URLs
then after every 6 mins it changes URLs?
if its too much to type out for examples, can you tell me what keyword i need to look up or what is the command name called?
thanks
:)
maximum interval is 65535 milliseconds (1.09225 minutes)
what can i use if i want the timer to be 6 mins long?
VB Code:
'create a Timer on your form and set Interval = 1000 (1 second or whatever) Private Sub Timer1_Timer() Static intCounter As Integer intCounter = intCounter + 1 If intCounter = 360000 Then '6minutes as passed WrbBrowser.Navigate "www.google.com" intCounter = 0 End If End Sub
i have no idea what i am doing.. . can you check what is wrong?
i been up all night trying to get this to work
:(
Code:Private Sub Form_Load()
Timer1.Interval = 1000 '1 sec
Timer1.Enabled = True
End Sub
'create a Timer on your form and set Interval = 1000 (1 second or whatever)
Private Sub Timer1_Timer()
Static intCounter As Integer
intCounter = intCounter + 1
If intCounter = 1000 Then '6minutes as passed
WebBrowser.Navigate ("www.google.com")
intCounter = 0
End If
End Sub
Well, that won't work because Integers can only hold a maximum of 32767.
I think you are better off using a string (what is the maximum for a Long?)
VB Code:
Private Sub Form_Load() Timer1.Interval = 1000 '1 sec Timer1.Enabled = True End Sub 'create a Timer on your form and set Interval = 1000 (1 second or whatever) Private Sub Timer1_Timer() Static strCounter As String Dim add As String add = "1" strCounter = strCounter + add If strCounter ="360000" Then '6minutes as passed WebBrowser.Navigate ("www.google.com") intCounter = 0 End If End Sub
Phreak
im kind of slow on this, give me a few and ill let you know how it works out for me
:)
i tryed the code provied, but it failed to load the webpage.
any idea what i maybe doing wrong?
im still not able to get it to work.
im sorry, i know im starting to get anoying. :blush:
Change strCounter (or intCounter) to Currency.
VB Code:
Dim strCounter As Currency Private Sub Form_Load() Timer1.Interval = 1000 '1 sec Timer1.Enabled = True End Sub 'create a Timer on your form and set Interval = 1000 (1 second or whatever) Private Sub Timer1_Timer() hAdd strCounter, "1000" MsgBox strCounter If strCounter = "360000" Then '6minutes as passed WebBrowser1.Navigate2 "www.google.com" strCounter = "0" End If End Sub Sub hAdd(a As Variant, b As Variant) strCounter = a + b End Sub
I have to sleep now, so thats the best I can come up with.
Phreak
Thank you for your time, sleep well. :wave:
-------------------
does anyone know where i should edit if i wanted to make it 6 mins?
hAdd strCounter, "1000" <---here?
MsgBox strCounter
If strCounter = "5000" Then '6minutes as passed <----or here?
is anyone able to help me in anyway?
Actually, going back to the original code might be most efficient:
VB Code:
Private Sub Form_Load() WebBrowser1.Navigate ("http://google.com") Timer1.Interval = 60000 '60 seconds; 1 minute Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Static iCounter As Integer iCounter = iCounter + 1 If iCounter = 6 Then frmBrowser.Show WebBrowser1.Navigate ("http://yahoo.com") End If If iCounter = 12 Then frmBrowser.Show WebBrowser1.Navigate ("http://cnn.com") Timer1.Enabled = False End If End Sub
Every 1 minute, the Timer1 code will execute. That makes iCounter increase itself by one every minute. Therefore, after 6 minutes (6 intervals of 1 minute), iCounter will be 6 and the first If block will execute. With the second one, after 12 minutes (12 1-minute intervals), it will execute.
With what phreak was doing, using a string is kinda innefficient, not to mention it would have to execute 1000 times per second. Longs hold up to 232/2 which is 2,147,483,648, and will work well there, though simply setting the interval to 60,000 (1 minute; 60 seconds; 60,000 ms) with an increment counter is much for efficient.
Thank you for the codes and taking the time to explain how it works. I have much love and respect for you, Thanks Jemidiah, SLH, EJ12N and «°°phReAk°°»