I really don't understand why concatenation fail

  • Thread starter Thread starter vodafone
  • Start date Start date
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
 
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.
 
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?
 
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
 
Back
Top