How to convert from array of byte to string? 
Author Message
 How to convert from array of byte to string?

all,

Ive tried to convert from byte array to string, why? because Im saving files
which may have the wrong characters in them, and they will not save, it
causes invalid file type error.

so I tried to take that and form a hash code, which happened to be 10x
larger than the string

using the example from the help menu

'Display the hash value to the console.

Dim b As Byte

For Each b In MessageBytes

' Console.Write("{0} ", b)

             hashed += CType(b, String)

Next b

MessageBytes = Nothing

it runs forever.  single stepping, it gets to the For Each, then adds hashed
+=  then next b,  hashed +=, next b  until its done, then gets to message
bytes, the instruction after that, then jumps back to the For again, and
starts over.  this was in a function and the return statement never got
called.  when it runs, it floods the screen with the messagebox at 2 per
second.

is it possible to take a sentence string and convert that to some
inoffensive and unique number?

thanks



Mon, 27 Dec 2004 04:13:15 GMT  
 How to convert from array of byte to string?
ok figured it out.

the real problem was the disk file save function rejecting the "/"
character, so I found the replace method which let me replace that with
something else.  so I could replace the "/" if the string had that, with the
substutite string "this is where the slash char was but I took it out for
now"

and it works fine.

thanks


Quote:
> all,

> Ive tried to convert from byte array to string, why? because Im saving
files
> which may have the wrong characters in them, and they will not save, it
> causes invalid file type error.

> so I tried to take that and form a hash code, which happened to be 10x
> larger than the string

> using the example from the help menu

> 'Display the hash value to the console.

> Dim b As Byte

> For Each b In MessageBytes

> ' Console.Write("{0} ", b)

>              hashed += CType(b, String)

> Next b

> MessageBytes = Nothing

> it runs forever.  single stepping, it gets to the For Each, then adds
hashed
> +=  then next b,  hashed +=, next b  until its done, then gets to message
> bytes, the instruction after that, then jumps back to the For again, and
> starts over.  this was in a function and the return statement never got
> called.  when it runs, it floods the screen with the messagebox at 2 per
> second.

> is it possible to take a sentence string and convert that to some
> inoffensive and unique number?

> thanks



Mon, 27 Dec 2004 08:40:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Converting string array to byte array

2. Need to convert a 16 byte array of bytes to 4 byte integer

3. Converting from string to array of bytes

4. Convert integers and strings to byte array

5. Convert Byte Array to a String

6. Converting between String and Byte Array

7. convert Byte array to string and vice veras

8. Convert Strings to Byte arrays and back

9. Convert a string to byte array

10. Convert an array of bytes to a string

11. StrConv function - Converting a byte array to a string

12. Converting a byte array to a string

 

 
Powered by phpBB® Forum Software