Results 1 to 6 of 6

Thread: String > Byte Array?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Question

    I almost feel too embarassed to ask this, but does anyone know a better way to convert a string to a byte array? I don't like using loops to process the string char by char. It's easy to convert a byte array to a string, you just use StrConv. There must be a VB function I'm missing or an API call. I mean a string is just a block of bytes in memory anyways. Anybody know a good way to do this?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    Thank you franz, beat me too it

    I actually only figured out how to do the str -> byte() because of this question.

    good place to learn, this is

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Thumbs up

    Yeah Thanks Franz, I really needed that
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633

    Wink

    Yeah Thanks Franz, I really needed that!

    Only one question, when would I use that or better yet, why would Songouki need to convert?

    Sorry, I don't work with byte array that much beside with the internet transfer control.
    Chemically Formulated As:
    Dr. Nitro

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Location
    Ottawa,ON,Canada
    Posts
    217

    Smile

    Thanks for the responses guys, I was beginning to think nobody was going to answer this thread! As for the solution, all I can say is D'oh! I tried to convert using StrConv, but it didn't work the first couple of times so I figured it wouldn't work at all! My own fault, live and learn, I guess.

    There are many useful reasons for wanting this, such as:
    • Many API calls require byte arrays instead of strings and won't work when modified to accept a string.
    • Processing and manipulating Binary files quickly.
    • Handling strings char by char (like C) and converting them back.

    ...and many more.

    Anyway, thanks again guys this really helps!

  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    I aggree, working with strings is fine in memory but when you're dealing with files binary is SOOOOO much faster and more flexible.

    I've often converted bytes() to string but not really needed to do the reverse, I saw this question and realizeed it was something I wanted to be able to do,


    Thanks SonGouki, excellent question (it got me off my arse to learn something )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width