I have a function below which is searching for a control on a page.
When i debug this function the first time it worked fine when i was
stepping through it then when i tried it again it error with the error
of object not set to an instance of an object I didn't change anything
between the two debugging attempts does any one know why it would
error.
Public Function getControl(ByVal theControl As ControlCollection, ByVal
toFind As String) As Control
Dim ctrl As Control = Nothing
For i As Integer = 1 To theControl.Count - 1
'If Not theControl.Item(i) Is Nothing Then
If theControl.Item(i).ID.ToString.ToUpper = toFind.ToUpper
Then
ctrl = theControl.Item(i)
Exit For
End If
'End If
Next
Return (ctrl)
End Function