Re: object refrence not set to an instance of an object ??

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



thanks, i rewrote it a little. and it works now :)


"_AnonCoward" wrote:

> "jeroen" <jeroen@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:C35A2670-C94F-4582-A202-AF6303429D9D@xxxxxxxxxxxxxxxx
> :
> : hello,
> :
> : i'm having a problem with the following piece of code. i use it to
> : read a string in an array, then search that string for ";;" symbols,
> : then i read what comes after that to a variable, witch goes to a text
> : box. but every time i run the subroutine, i get an "Object reference
> : not set to an instance of an object." error at the time it reaches
> : "start = line.IndexOf(";;")"
> :
> : also, wenn i set a breakpoint to debug it, de breakpoint red point's
> : get a question mark in it(meaning the code isn't avalible?). what's
> : that all about ?
> :
> : Code:
> : Dim line, start2 As String
> : Dim start As Integer
> : Dim counter As Integer = 0
> :
> : If comments.Count = 0 Then
> : Exit Function
> : End If
> :
> : While counter < countedcomments
> : counter += 1
> : line = comments(counter)
> : If line.StartsWith(fotos(positionarray)) Then
> : Exit While
> : End If
> : End While
> :
> : start = line.IndexOf(";;")
> :
> : If Not start = -1 Then
> : txtbijschrift.Text = ""
> : Exit Function
> : End If
> : start2 = Mid(line, start)
> : txtbijschrift.Text = start2
> :
> : thanks for the help :)
> : jeroen
>
>
> This error is indicating that the 'line' object is a null reference
> (Nothing). You did not instantiate your line object when you declared it
> and, evidently, it is not being assigned inside your while loop. My
> guess is this is because 'counter' starts out as greater than
> 'countedcomments'. In that case, the statement 'line = comments(counter)
> is never beening reached. If so, then when you attempt to access the
> indexOf function of the string class, the code objects because 'line' is
> uninstantiated (it remains a null value).
>
>
> Try instantiating the 'line' variable when you declare it (Dim line As
> String = "") or check to ensure the variable is referencing a live
> object prior to the state where your error is occuring. For example:
>
>
> If line Is Nothing Then
> 'add whatever logic you feel
> 'is appropriate here
>
> Else
> start = line.IndexOf(";;")
>
> If Not start = -1 Then
> txtbijschrift.Text = ""
> Exit Function
> End If
> start2 = Mid(line, start)
> txtbijschrift.Text = start2
>
> End If
>
> HTH
>
> Ralf
>
>
>
.



Relevant Pages

  • Re: Problem with SQL UDF
    ... I have not had a chance to debug this further, but I can confirm the same results on v5r3 & v5r4. ... The RVAR is reset to blanks sometime after the call to the API and before the source statement immediately following; ... DECLARE RLIB VARCHAR; ... If the file is not found the function ends in error, due to the missing API error structure (with a CPF9812 in the joblog as expected), running under debug I can see in the joblog that QUSROBJD was called successfully, if I change the proc name with something that doesn't match a program or service-program name, I can see in the joblog that the program was not found in *LIBL, so I'm pretty sure that the call takes place. ...
    (comp.sys.ibm.as400.misc)
  • Re: Oracle Dates
    ... target month is shorter than source month ... last day of the target months, so the first question mark is 30 june ... for loopctr in 1..100 loop ...
    (comp.databases.oracle.server)
  • Re: Oracle Dates
    ... =A02 =A0from dual; ... last day of the target months, so the first question mark is 30 june ... 11     end loop; ...
    (comp.databases.oracle.server)
  • Need suggestions how to debug crash in Application::Run(mainForm)?
    ... Object reference not set to an instance of an object. ... If I run the debug .exe from command line, ... There is no Form load event in this form, so as far as I can tell there is no code of my own run between the end of the main form's init code, and this crash. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: bad dll calling convention in debug only
    ... >> Are you also using the debug version of the MFC library? ... >> debugging the DLL. ... >> Create a typelib and use that to replace the Declare Directives. ... I also recommend Bruce McKinney's source for a WinAPI typelib. ...
    (microsoft.public.vb.general.discussion)