I really don't understand why concatenation fail

V

vodafone

I've written the code below.

Dim lastIdx As Int32
Dim appo As System.String
Dim s As String

Do
mStream.Read(ByteArray, 0, nBytes)

s = encoding.GetString(ByteArray)
s = appo & s

Dim m As Match = regExp.Match(s)

lastIdx = 0

Do While m.Success
Dim g As Group = m.Groups(0)

Dim tmp As String = (s.Substring(lastIdx, g.Index - lastIdx))
Console.WriteLine(tmp)

lastIdx = g.Index + 1
m = m.NextMatch
Loop

appo = New String(s.Substring(lastIdx))
Loop While (nBytes > 0)


I don't understand why, the second time the main do loop pass throught
the concatenation s = appo & s, s doesn't contain the concatenation,
but only the value of appo.

Some idea? I tried all the imaging thing, without result. I suppose
that could be the encoding that create confusion, but I didn't verified
yet.
Meanwhile some suggestion will be appreciated.

Thanks
Andrea
 
H

Herfried K. Wagner [MVP]

vodafone said:
Dim lastIdx As Int32
Dim appo As System.String
Dim s As String

Do
mStream.Read(ByteArray, 0, nBytes)

s = encoding.GetString(ByteArray)
s = appo & s

Dim m As Match = regExp.Match(s)

lastIdx = 0

Do While m.Success
Dim g As Group = m.Groups(0)

Dim tmp As String = (s.Substring(lastIdx, g.Index - lastIdx))
Console.WriteLine(tmp)

lastIdx = g.Index + 1
m = m.NextMatch
Loop

appo = New String(s.Substring(lastIdx))
Loop While (nBytes > 0)


I don't understand why, the second time the main do loop pass throught
the concatenation s = appo & s, s doesn't contain the concatenation,
but only the value of appo.

First, check the length of 's' to make sure it contains some text. In
addition to that, it could be possible that the string contains a null
character which causes the IDE to treat this character as the end of the
string although the string contains even more characters.
 
O

Oenone

Herfried said:
In addition to that, it could be possible that the string contains a null
character which causes the IDE to treat this character as the end of
the string although the string contains even more characters.

Incidentally, do you know whether they have fixed this for VB2005?
 
V

vodafone

String contain a lot of vbcrlf character. May be that this is treated
as null.

But the strange thing is that on the first read, vbcrlf or not, s
return fine. Problems start on the second loop.

Any other idea?

Thanks
Andrea
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top