Object Reference Error.
Here is some code of mine:
Public PassedLine As String
Dim myValue As String = PassedLine
If myValue.IndexOf("Jason") > 0 Or myValue.IndexOf("Gaylord") > 0 Then
UpdateType = 1
Return
End If
UpdateType = 2I am getting an error on the IndexOf statement saying <b>Oject reference not set to an instance of an object</b>.
To add to Erik's response: You have to remember that a String is an object (that is, a reference type) in .NET. THerefore, if PassedLine has never been initialized, it's going to be Nothing. Attempting to call a method of, or work with a property of, an object that's Nothing (or null, in C#), will give you this error.
In C#, FWIW, this code would have raised a warning at compile time, because you're attempting to use an uninitialized variable.
Sorry, should have mentioned that this is in the same MDI (yes I'm still working on it! :( ) application. The parent refrences the property and sets the value. I know the value works because I had a MessageBox test it. It comes across as a string.
Sorry, PassedLine must be set to Nothing in order for that error to occur, if that's really the only code involved. I was worried that there was an "order of operations" problem with the Or and > operators, but that wasn't it. I tried the code, and the only way I get that error is if PassedLine (and/or myValue is Nothing, but I don't see how that can happen unless PassedLine is Nothing). Can you add a Debug.WriteLine statement right before you attempt to work with myValue and really verify that it's not Nothing?
Well, I ended up using the same form and not using another form to bring in the values. I continued to receive an error with the form. If this need arises again, I'll let you know! ;)