Question Really Stuck... Can't pass variable from one form to another..

NeedHelp

Member
Joined
Jun 5, 2011
Messages
7
Programming Experience
3-5
I have one form, which the user enters upto 5 websites then clicks go -
I have on the second form, the one with the webbrowser. A timer which checks if the web browser is busy then either a green light or black image will be shown along side the assocaited input box on the first form.
I am finding it impossible to feed variables into the clock through ByVal, like I would a subroutine or function.

Private Sub ActiveMe_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActiveMe.Tick
If ((WebBrowser1.IsBusy)) Then
Hey.BackColor = Color.Black
Else
Hey.BackColor = Color.Green
End If
End Sub


'Error message says Hey is not declared, as i can't pass it through to timer

The variable Hey is determined by the first form - Which picturebox.
I have an if statement which simply says if inputbox one has url enter then Hey = Picturebox1, If input box2 has url entered then Hey= Picturebox2 etc.


What I want is the timer to check the page has completed loading or is still loading or refresing and the appropriate green or black to be shown aside url input box on first form

I considered using a sub or procedure to act as a clock (a large for loop with another for loop within it, acting as a delay). But found this slowed down theapp to the point of crashing it.

Plz help guys
 
First up, you should not be using a Timer. You should be handling the appropriate events of the WebBrowser control. The Navigated event is raised when the control starts loading a page and the DocumentCompleted event is raised when it finishes. You would provide feedback to the user in those event handlers.

As for how to provide the feedback, if 'Hey' is declared in Form1 then you have to specify that when you use it elsewhere. In Form2, the name 'Hey' is meaningless, so you must qualify the name with the name of the form it belongs to.
 
Back
Top