Re: String Variable containing "R" has zero length??? mscomm1.input

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Al Reid (areidjr_at_reidDASHhome.com)
Date: 11/02/04


Date: Tue, 2 Nov 2004 08:43:33 -0500


"mike" <spamme0@netscape.net> wrote in message news:41878DE9.4080803@netscape.net...
> String Variable containing "R" has zero length??? mscomm1.input
> I can't read from the serial port.
>
> Visual Basic 6.0 version 8176
> Windows 98SE
>
> Here's the program.
>
> dim c as string
> dim d as integer
> test:
> c = mscomm1.input
> debug.print c, len(c)
> d = asc(c) 'Program stops here error message 5
> goto test
>
> There's more to it, setting up the speed and handshake, opening the port
> etc.
>
> I have the input buffer length set to 1, but doesn't seem to matter.
> I had a test after the read to go to test: if c = "" but that wasn't
> fruitful. Length is zero but it's not null, see below.
>
> I send the string "Ready" into the serial port.
>
> The program aborts on the line indicated error code 5 illegal
> procedure call or argument.
>
> When the program stops in the debugger, you can hover the cursor over
> variables and see their values.
>
> The variable c contains "R" which is correct.
> len(c) is 0 which is NOT correct.
> The debug print statement prints a tab and a zero. No "R", just the
> length of zero.
>
> I've pulled out the last of my hair trying to figure out how to fix this.
> I've tried terminating any processes that might be in contention for the
> serial port, but no help. The first character is being received ok.
> How can a string variable containing "R" have a length of zero???
>
> Suggestions?
>
> Thanks, mike
>
>
> --
> Return address is VALID.
> 500MHz Tek DSOscilloscope TDS540 $2200
> Wanted, 12.1" LCD for Gateway Solo 5300. Samsung LT121SU-121
> Bunch of stuff For Sale and Wanted at the link below.
> http://www.geocities.com/SiliconValley/Monitor/4710/
>

First, it has been ages since I used the Comm Control. However, everything you have stated is consistent with the variable "c"
containing an empty string rather that the character "R".

Debug.Print "", Len("")
Debug.Print Asc("")

gives the same results you stated above.

You need to find out why the com control is returning an empty string.

Hopefully, someone else can help on that.

-- 
Al Reid
How will I know when I get there...
If I don't know where I'm going?


Relevant Pages

  • Re: Adding a 5ms delay in between sending bytes to a controller
    ... > must either assign a string or an array of bytes to the output ... Armin comm1 is the com component for the serial port. ... Dim Len As Byte = 6 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: String Variable containing "R" has zero length??? mscomm1.input
    ... >>I can't read from the serial port. ... >>dim d as integer ... >>Bunch of stuff For Sale and Wanted at the link below. ... > You need to find out why the com control is returning an empty string. ...
    (microsoft.public.vb.controls)
  • Re: Empty string comparisons
    ... I would recommend using "Is" to distinguish between Nothing and an empty string. ... Dim b6 As Boolean = ... You have to use String.Equals to distinguish between Nothing and an empty string. ... Instant VB: C# to VB converter ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Calulated form field when result is null and zero
    ... The reason it works whether or not the string is empty is that strings are ... > Whether str has a value below or is an empty string does not seem to ... > Dim tm As Double ... >> The performance purists insist that you should test for empty strings ...
    (microsoft.public.word.vba.general)
  • Split function behaviour...
    ... Dim test As String ... Where does the empty string come from? ...
    (microsoft.public.dotnet.framework.compactframework)