string to byte array


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: string to byte array

  1. #1
    Join Date
    Mar 2006
    Location
    bangalore ,india
    Posts
    29

    string to byte array

    i have pictures in my project stored as byte array.
    i need to convert these byte array into strings and vice versato set my clipboard totally in string format.
    going through the forum i found out the following code to convert byte array to strings
    Public Function ByteArrayToString(bytArray() As Byte) As String
    Dim sAns As String
    Dim iPos As String

    sAns = StrConv(bytArray, vbUnicode)
    iPos = InStr(sAns, Chr(0))
    If iPos > 0 Then sAns = Left(sAns, iPos - 1)

    ByteArrayToString = sAns

    End Function
    can anyone provide me the reverse process codes that is from string to byte array
    aks79,bangalore
    god gave me nothing i wanted,
    he gave me everything i needed.

  2. #2
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    Dim t() as Byte
    Dim s as string

    s = "Hello World"
    t = s

    And your done!

    Just remember, if your using narrow characters (non-Unicode) then every other value in the byte array will be 0 (the wide end of the character).

  3. #3
    Join Date
    Mar 2006
    Location
    bangalore ,india
    Posts
    29
    i am converting images in my project to byte arrays and then converting them into unicode string.
    now can anyone be more specific in replying i.e to convert string to byte array because i want to reconstruct the image
    aks79,bangalore
    god gave me nothing i wanted,
    he gave me everything i needed.

Similar Threads

  1. Packed Data(Comp-3, etc)
    By Marcos in forum VB Classic
    Replies: 3
    Last Post: 01-25-2006, 12:18 PM
  2. Input string was not in a correct format
    By mdengler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:32 PM
  3. verify local admin
    By Patrick Comeau in forum VB Classic
    Replies: 6
    Last Post: 03-22-2001, 11:50 PM
  4. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 04:45 PM
  5. Database problems
    By Robert Rieth in forum VB Classic
    Replies: 1
    Last Post: 04-11-2000, 04:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center