Chr(3) Defines the username & chr(0) states the end of that field
Chr(4) Defines the Password & chr(0) states the end of that field
Chr(5) Defines the Software Version & chr(0) states the end of that field
The last 2 are single characters and do not need chr(0)
MyString=Chr(3) & config.Username & Chr(0) _
& Chr(4) & config.Password & Chr(0) _
& Chr(5) & config.Airpack_Login_Version & Chr(0) _
& Chr(25) & Chr(config.Receive) _
& Chr(26) & Chr(config.Transmit)
In VB6 this would create an appropriate String to be sent through the socket
but in Dot Net it gets to the first chr(0) then discards the rest.
Anyone have any advice on this one.
Thanks in advance
Chris Wilmot
How are you determining that the string is being truncated at the first
Chr$(0)? If you check the string length, does it also reflect a string
that has been truncated?
I tried the following code (I just substituted values because I didn't
know what your actual values were):
Private Sub Button2_Click(...) Handles Button2.Click
Dim sTest As String
sTest = VB.Chr(3) & "UserName" & VB.Chr(0) & _
VB.Chr(4) & "Password" & VB.Chr(0) & _
VB.Chr(5) & "LoginVersion" & VB.Chr(0) & _
VB.Chr(25) & VB.Chr(23) & _
VB.Chr(26) & VB.Chr(6)
'This MsgBox show the length of the string correctly
MsgBox(sTest.Length)
'These two lines display only up to the first Chr(0)
Debug.WriteLine("sTest is [" & sTest & "]")
MsgBox(sTest)
End Sub
The first message box show the correct string length of 38 characters.
But the Debug.WriteLine and the MsgBox truncate at the first zero byte.
Is the socket actually truncating the string or is a messagebox or
writeline doing it?
I suspect that your string is probably OK, just the display of it is
affected.
Hope this helps,
Chris
--
If you don't like lunchmeat, please remove it from my e-mail address to
send me an e-mail
"Chris Wilmot" <chris....@mtsgroup.co.uk> schrieb:
Are you sure? Notice that some controls, the MsgBox function and the IDE
have problems displaying strings that contain a NullChar.
HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Even though VB.Net says I am sending nothing in the debug window after the
message is fully compiled it does actually send the relevant fields.
So if the debug window doesn't show the true condense of a string and when I
hover over the field that doesn't show it either then how am I suppose to
step through my application??
Chris Wilmot
"Chris Wilmot" <chris....@mtsgroup.co.uk> wrote in message
news:%23MXbR6C...@TK2MSFTNGP12.phx.gbl...