Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi to all
I'm trying to concatenate a array of bytes (0-255) to a single string, like this: Private conteudoBytes(2000) As Byte Private conteudoStr As String When I try to do: For i = 0 To 2000 conteudoStr = conteudoStr & Chr(conteudoBytes(i)) Next i conteudoStr have the concatenated string to the first null character (0x00), exclusively. I don't know why it stops there. conteudoBytes(2000) have the contents of a binary file. Am i doing this the wrong way? Sincere regards and thank you in advance for reading, Marco |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe something like this:
Private conteudoBytes(2000) As Byte Private conteudoStr*2001 As String For i = 0 To 2000 if conteudoBytes(i) < 0 then Mid(conteudoStr,i+1,1) = Chr(conteudoBytes(i)) end if Next i -- Regards, Tom Ogilvy "marco" wrote: Hi to all I'm trying to concatenate a array of bytes (0-255) to a single string, like this: Private conteudoBytes(2000) As Byte Private conteudoStr As String When I try to do: For i = 0 To 2000 conteudoStr = conteudoStr & Chr(conteudoBytes(i)) Next i conteudoStr have the concatenated string to the first null character (0x00), exclusively. I don't know why it stops there. conteudoBytes(2000) have the contents of a binary file. Am i doing this the wrong way? Sincere regards and thank you in advance for reading, Marco |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sure that it stops there? If you were testing things by the
message box function, the msgbox function won't display past a null character - but the data is there in the string nevertheless: Sub test() Dim S As String S = "Hello" & Chr(0) & "World" Debug.Print S 'prints "Hello World" in the immediate window MsgBox S 'just displays "Hello" MsgBox Mid(S, 7) 'displays "World" - the data is there and still extractable MsgBox Len(S) 'displays 11 End Sub Hth -John Coleman On Mar 12, 2:30 pm, "marco" wrote: Hi to all I'm trying to concatenate a array of bytes (0-255) to a single string, like this: Private conteudoBytes(2000) As Byte Private conteudoStr As String When I try to do: For i = 0 To 2000 conteudoStr = conteudoStr & Chr(conteudoBytes(i)) Next i conteudoStr have the concatenated string to the first null character (0x00), exclusively. I don't know why it stops there. conteudoBytes(2000) have the contents of a binary file. Am i doing this the wrong way? Sincere regards and thank you in advance for reading, Marco |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sure that it stops there? If you were testing things by the
message box function, the msgbox function won't display past a null character - but the data is there in the string nevertheless: Sub test() Dim S As String S = "Hello" & Chr(0) & "World" Debug.Print S 'prints "Hello World" in the immediate window MsgBox S 'just displays "Hello" MsgBox Mid(S, 7) 'displays "World" - the data is there and still extractable MsgBox Len(S) 'displays 11 End Sub Hth -John Coleman On Mar 12, 2:30 pm, "marco" wrote: Hi to all I'm trying to concatenate a array of bytes (0-255) to a single string, like this: Private conteudoBytes(2000) As Byte Private conteudoStr As String When I try to do: For i = 0 To 2000 conteudoStr = conteudoStr & Chr(conteudoBytes(i)) Next i conteudoStr have the concatenated string to the first null character (0x00), exclusively. I don't know why it stops there. conteudoBytes(2000) have the contents of a binary file. Am i doing this the wrong way? Sincere regards and thank you in advance for reading, Marco |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That's it !!
MsgBox() doesn't show chr(0), but the Immediate Window does. Thanks alot, you saved me of alot of (debugging) time. Thanks to all of you. Marco On Mar 12, 8:47 pm, "John Coleman" wrote: Are you sure that it stops there? If you were testing things by the message box function, the msgbox function won't display past a null character - but the data is there in the string nevertheless: Sub test() Dim S As String S = "Hello" & Chr(0) & "World" Debug.Print S 'prints "Hello World" in the immediate window MsgBox S 'just displays "Hello" MsgBox Mid(S, 7) 'displays "World" - the data is there and still extractable MsgBox Len(S) 'displays 11 End Sub Hth -John Coleman On Mar 12, 2:30 pm, "marco" wrote: Hi to all I'm trying to concatenate a array of bytes (0-255) to a single string, like this: Private conteudoBytes(2000) As Byte Private conteudoStr As String When I try to do: For i = 0 To 2000 conteudoStr = conteudoStr & Chr(conteudoBytes(i)) Next i conteudoStr have the concatenated string to the first null character (0x00), exclusively. I don't know why it stops there. conteudoBytes(2000) have the contents of a binary file. Am i doing this the wrong way? Sincere regards and thank you in advance for reading, Marco- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need Help With String Concatenation | Excel Worksheet Functions | |||
Need Help With String Concatenation | Excel Worksheet Functions | |||
What is the Null character? | Excel Discussion (Misc queries) | |||
String concatenation | Excel Programming | |||
string concatenation | Excel Programming |