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

From: mike (spamme0_at_netscape.net)
Date: 11/02/04


Date: Tue, 02 Nov 2004 05:56:11 -0800

Al Reid wrote:
> "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.
>
>

I hear you, but why does the debugger tell me the string contains
"R"???? Which is exactly what it should contain....
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/

Quantcast