Here is the sample:
Dim TestString As String = 'Hello,' & Chr(0) & 'World' MsgBox(TestString, , 'TestString.Length=' & TestString.Length.ToString)
Result – Messagebox shows ‘Hello,’ with title says TestString.Length=12
I guess the chr(0) is treated as the end of zero terminated string, but it’s not what i want.
What the right method to operate with Chr(0) ?
I’ve also tried this in asp.net with no avail. I’m sending the string over a socket. My problem is that when I’m debugging it the whole string doesn’t add up. I need to send them a rather large string for it. What comes up really on the message window doesn’t bother me. I used the above as an example. I just need when putting the multiple variables that it adds correctly to the string. Another example of it would be
'SCORE'.ToString.PadRight(8, chr(0)) & '3.0'.ToString.PadRight(10, chr(0)) & '0'.ToString.PadRight(1, '0')
the expected value would score3.00
What I get though is score3.0
The sample code in the questioner’s example (‘SCORE’.ToString…) works fine for me in a console application. The VS2005 debugger does not show the string correctly, but it outputs to the console just fine. So, my feeling is either that you think it’s incorrect because the debugger wrongly says so or your output string is not long enough to include all the padding.