Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default String concatenation having null character

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default String concatenation having null character

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default String concatenation having null character

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default String concatenation having null character

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default String concatenation having null character

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With String Concatenation Rick Rothstein Excel Worksheet Functions 6 September 15th 11 10:42 PM
Need Help With String Concatenation Xt Excel Worksheet Functions 1 September 15th 11 09:47 PM
What is the Null character? Quinn Ramsey Excel Discussion (Misc queries) 5 May 24th 08 05:24 PM
String concatenation shishi Excel Programming 3 August 9th 05 02:24 AM
string concatenation Mike NG Excel Programming 2 August 15th 03 03:06 AM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"