String Problems

  • Thread starter Thread starter James Proctor
  • Start date Start date
J

James Proctor

Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString(Data)

The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.

Thanks

James
 
James Proctor said:
Hi, im having a couple of problems with strings. When i
use this code.

Dim Data(numBytes) As Byte
_Socket.Receive(Data)
TempData = System.Text.ASCIIEncoding.ASCII.GetString(Data)

The line above is actually
System.Text.Encoding.ASCII.GetString(Data)
but it is the same.

I guess you know that ASCII is 7-bit only?
The string it returns is always in this format "String
and i cant understand why it is not in the
format "String" could someone explain what is going on?
Its a bit annoying because i can compare strings.

Probably a chr(0) within the string. The IDE displays only the part on the
left of chr(0), but the string contains more chars.
 
-----Original Message-----
(Data)

The line above is actually
System.Text.Encoding.ASCII.GetString(Data)
but it is the same.

I guess you know that ASCII is 7-bit only?


Probably a chr(0) within the string. The IDE displays only the part on the
left of chr(0), but the string contains more chars.


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.
I should probs have explained that i see "String instead
of "String" when i debug the program and put the mouse
over the varible. It seems strange. It must be something
im missing out.

JP

http://www.ebmis.co.uk
 
James said:
I should probs have explained that i see "String instead
of "String" when i debug the program and put the mouse
over the varible.


Yes, that's how I understood your question. I think my answer covers this
issue. Maybe *I* missed something?
 
James,
As Armin suggested, you have a chr(0) in your string!

More then likely because your data array is one byte too long, remember that
numBytes in:

Is the high bound, not number of elements!

Try

Hope this helps
Jay
 
Back
Top