Help!

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
I have got some really horrible debugging message, and to be honest i havent got a clue what is wrong!

I have pasted the section of code, that i believe is throwing up the error.

Thanks

Visual Basic:
                    'Removes the current line from the 
While i = 1
                'Finds the end of this line/start of next (by using FF) *1.1
                shtLineStart = InStr(1, strWaitingFromBuffer, Chr(1))
                'MsgBox(shtLineStart)
                shtLineEnd = InStr(shtLineStart, strWaitingFromBuffer, Chr(12))
                'MsgBox(shtLineEnd)
                'Would only be 0 if there was no more complete lines to process
                If shtLineEnd > 0 And shtLineStart > 0 Then
                    'Fines the current line, and puts in into strCurrentLine
                    strCurrentLine = strWaitingFromBuffer.Substring(shtLineStart, shtLineEnd - shtLineStart)
strWaitingFromBuffer, 
                    'so its only dealt with once
                    strWaitingFromBuffer = strWaitingFromBuffer.Remove(0, shtLineEnd)

                    'Searches through the current line removing a linefeed IF there is 1
                    intCharToRemove = InStr(j, strCurrentLine, Chr(10))
                    If intCharToRemove > 0 Then
                        ' MsgBox("in if statement")
                        'If theres a character to remove REMOVE IT!
                        strCurrentLine = strCurrentLine.Remove(intCharToRemove - 1, 1)
                        'MsgBox(Str(intCharToRemove))
                    End If

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Argument 'Start' must be greater or equal to zero.
at Microsoft.VisualBasic.Strings.InStr(Int32 Start, String String1, String String2, CompareMethod Compare)
at RoverComPort.modReadBuffer.ReadBuffer() in C:\Visual Studio Projects\rover_com_port_listener\rover_com_port_listener\modReadBuffer.vb:line 55
at RoverComPort.frmRoverBMain.tmrReadCommBuffer_Tick(Object sender, EventArgs e) in C:\Visual Studio Projects\rover_com_port_listener\rover_com_port_listener\frmMain.vb:line 660
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr idEvent, IntPtr dwTime)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
RoverComPort
Assembly Version: 1.0.1413.24993
Win32 Version: 1.0.1413.24993
CodeBase: file:///C:/Visual%20Studio%20Projects/rover_com_port_listener/rover_com_port_listener/bin/RoverComPort.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
AxInterop.MSCommLib
Assembly Version: 1.1.0.0
Win32 Version: 1.1.0.0
CodeBase: file:///C:/Visual%20Studio%20Projects/rover_com_port_listener/rover_com_port_listener/bin/AxInterop.MSCommLib.DLL
----------------------------------------
AxInterop.MSFlexGridLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Visual%20Studio%20Projects/rover_com_port_listener/rover_com_port_listener/bin/AxInterop.MSFlexGridLib.DLL
----------------------------------------
Interop.MSCommLib
Assembly Version: 1.1.0.0
Win32 Version: 1.1.0.0
CodeBase: file:///C:/Visual%20Studio%20Projects/rover_com_port_listener/rover_com_port_listener/bin/Interop.MSCommLib.DLL
----------------------------------------
Interop.MSFlexGridLib
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Visual%20Studio%20Projects/rover_com_port_listener/rover_com_port_listener/bin/Interop.MSFlexGridLib.DLL
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 7.0.5000.0
Win32 Version: 7.10.3052.4
CodeBase: file:///c:/winnt/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
----------------------------------------
Accessibility
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/winnt/assembly/gac/accessibility/1.0.5000.0__b03f5f7f11d50a3a/accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
on the line
shtLineEnd = InStr(shtLineStart, strWaitingFromBuffer, Chr(12))

what is the value of shtLineStart?

and the value of j in

intCharToRemove = InStr(j, strCurrentLine, Chr(10)) ?

Also you shoud be using the strings .IndexOf method rather than the InStr function.
 
Thank you yet again!

>on the line
>shtLineEnd = InStr(shtLineStart, strWaitingFromBuffer, Chr(12))
>what is the value of shtLineStart?

It really depends on what the line below turns up - from memory on this example i think it was 267.
Visual Basic:
shtLineStart = InStr(1, strWaitingFromBuffer, Chr(1))


>and the value of j in intCharToRemove = InStr(j, strCurrentLine, Chr(10)) ?

1 in this case i believe, but to be honest i cant remember, and i cant get to the project until tuesday now.


>Also you shoud be using the strings .IndexOf method rather >than the InStr function.

Cheers... I seem to get told things like this alot, but to honest no one ever explains why. Is it that instr is left overs from VB6 or something?
 
Back
Top