So I have this code:

String^ main = "";
			 if(main == web->Url->ToString()){
				 MessageBox::Show("Hello", "WIN");

and it's attached to a timer that ticks every 100 milliseconds. Oh yeah, and web is the web browser in VC++.

But when I run, I get this error:

An unhandled exception of type 'System.NullReferenceException' occurred in Lockerz.exe

Additional information: Object reference not set to an instance of an object.

(The project is named lockerz)
and when I used the red-dot thingy (that pauses the code at the line), it pointed to the "if" as being the problem...

So, any ideas?

I think what's happening (based on some experimenting) is that the code is progressing much faster than the website is loading. Therefore there is no url in place(it's undefined since the site hasn't loaded) by the time execution gets to your if statement.
Check out the DocumentCompleted Event of the web browser control: . You can find it by highlighting the web browser control, going over to properties on the right hand side, and double click the cell next to DocumentCompleted. Now do your url comparison within that method. For some odd reason when I tested it with a message box in the DocumentCompleted the box was being displayed twice but you should be able to find a way around that.

This question has already been answered. Start a new discussion instead.