Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Question on Unicode and string conversions in VBA
Given the following two code snippets, how come I get different output?
Code: Sub test() Dim str As String Dim b() As Byte str = "hello" b() = str str = "" For i = LBound(b) To UBound(b) str = str & b(i) & " " Next i Debug.Print str End Sub The above produces the following output: Code: 104 0 101 0 108 0 108 0 111 0 second procedu Code: Sub test2() Dim str As String Dim b() As Byte str = "hello" b() = StrConv(str, vbUnicode) str = "" For i = LBound(b) To UBound(b) str = str & b(i) & " " Next i Debug.Print str End Sub Which produces this output: Code: 104 0 0 0 101 0 0 0 108 0 0 0 108 0 0 0 111 0 0 0 My question is: why the additional zeroes from the second procedure? Assigning a string to a byte array fills the byte array with the unicode characters, and I thought this was essentially what the StrConv function did (with vbUnicode option). Can anyone settle my curiosity? Thanks for any/all replies! Best regards Richard |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
conversions | Excel Worksheet Functions | |||
Conversions | Excel Worksheet Functions | |||
simple unicode question | Excel Discussion (Misc queries) | |||
How to show unicode String ? | Excel Programming | |||
Unicode string parsing? Please help! | Excel Programming |