User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 422,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,878 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1442 | Replies: 3 | Solved
Reply
Join Date: Jun 2006
Posts: 2
Reputation: RichardSchollar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RichardSchollar RichardSchollar is offline Offline
Newbie Poster

Unicode and Strings

  #1  
Jun 1st, 2006
Given the following two code snippets, how come I get different output?
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:
104 0 101 0 108 0 108 0 111 0 
second procedure:
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:
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! Richard
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator
Join Date: Jun 2006
Posts: 2
Reputation: RichardSchollar is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
RichardSchollar RichardSchollar is offline Offline
Newbie Poster

Re: Unicode and Strings

  #3  
Jun 2nd, 2006
Comatose - many thanks for the links. The last one was exceptionally helpful. That has sorted out a problem I was seriously confused by. Thanks again!Richard
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Unicode and Strings

  #4  
Jun 2nd, 2006
You're Welcome!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 3:41 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC