decrypt Posted October 17, 2003 Posted October 17, 2003 (edited) Hi, I'm making a program that continueally refreshes the current website when you click a button. Here is the code: [color=blue]Private Sub[/color] Button2_Click([color=blue]ByVal[/color] sender [color=blue]As[/color] System.Object, [color=blue]ByVal[/color] e [color=blue]As[/color] System.EventArgs) [color=blue]Handles[/color] Button2.Click [color=blue]Dim[/color] i [color=blue]As Integer[/color] [color=blue]For[/color] i = 1 [color=blue]To[/color] TextBox2.Text [color=green]'Loop[/color] AxWebBrowser1.Refresh() [color=green]'Refresh the page[/color] Timer1.Interval = TextBox3.Text [color=green]'Time inbetween refreshing (time for page to load)[/color] Timer1.Enabled = [color=blue]True[/color] [color=green]'Start the timer[/color] [color=blue]Next[/color] [color=blue]End Sub[/color] What's wrong with it? It only refreshes once, and then it doesn't do anything. Edited October 17, 2003 by decrypt Quote
Moderators Robby Posted October 17, 2003 Moderators Posted October 17, 2003 Maybe I'm missing something here but it probably is looping the number of times you expect but it happens so fast that you don't see it. I think that you need to move the Refresh into your Timer Event, so that it refreshes on each Interval. Also, wouldn't Net.WebClient() do what you need (instead of the ActiveX) Quote Visit...Bassic Software
decrypt Posted October 31, 2003 Author Posted October 31, 2003 Timer1.Interval = TextBox3.Text 'Time inbetween refreshing (time for page to load) As you see there textbox3.text sets the time inbetween refreshing. (I normally do around 2000 milliseconds and it still doesn't refresh) How do you set it in the timer event? And Also how do you use the Net.WebClient() :P Quote
Raven76 Posted November 5, 2003 Posted November 5, 2003 I think you are confused on the use of the timer. You have the right idea, but your missing slightly. Timer1.Interval = TextBox3.Text 'Time inbetween refreshing (time for page to load) In the code above you have set the timer to raise an event at the specified interval once it is enabled. So far so good. Timer1.Enabled = True 'Start the timer Now you have enbled the timer to raise it's event at each interval. Still doing good. AxWebBrowser1.Refresh() 'Refresh the page This causes the refresh, but it's in the wrong place. You need to have it in a seperate sub that is triggered by the Timer1 event. For example: In the declarations section: Private m_iCounter as integer = 0 'Counter variable. Sub #1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Set timer properties and start running. Timer1.Interval = TextBox3.Text 'Time inbetween refreshing (time for page to load) Timer1.Enabled = True 'Start the timer End Sub Sub #2 Private Sub Timer1_EVENTNAME() 'Replace "EVENTNAME" with the real event trigger name which I can't remember. 'runs this code whenever timer fires If m_intCounter <= CInt(Textbox2.Text) Then 'If counter less than textbox... AxWebBrowser1.Refresh() '...Refresh the page... m_intCounter + 1 '...and add to counter... Else Timer1.enabled = False '...Otherwise, Stop timer... m_intCounter = 0 '...and reset counter. End If End Sub This is just example code and is untested. Hope this helps. Good luck. Quote
decrypt Posted November 9, 2003 Author Posted November 9, 2003 Yay i got it working with a bit of editing to your code! Thank you! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.