15. oktober 2002 - 17:12Der er
6 kommentarer og 1 løsning
Converting byte(n) to String to do Replace(xxx)
"My friend" is having problems doing replacement in an byte array.
"He" has a funktion(Inet-MS internet Transfer control 6.0) that returns a byte array, this array consists of text. In order to make this replacement he tries to use the Replace() funktion, but in order to do this he first has to convert this byte array into a string.
This function is used: -------------------------------- Function MyByteToCstr(ByteArr() As Byte) As String
Dim RetVal As String Dim i As Integer
RetVal = ""
For i = 0 To UBound(ByteArr()) - 1 RetVal = RetVal & Chr(CInt(ByteArr(i))) Next i
MyByteToCstr = RetVal End Function -----------------------------------------
This function will give an errormessage "OVERFLOW (-6)"... This overflow error is thrown when the byte array is to large(we used 67 000 byte). 1500 byte works fine.
How could "he" convert this byte-array, does anyone have another idea how "he" could make a replace in a byte-array?
Thanks for trying! "my friend" is using a byte array: ------------------------ Dim var1() as byte Dim var2 as String
Var2 = Var1() ------------------------ ...does not work = the Var2 gets an oddlooking string, I would like every byte in the bytearray to be represented by one character in the String.
Ahaaa... I see, but wouldn't "my friends" function above with this loop: ------------------------------------------- For i = 0 To UBound(ByteArr()) - 1 RetVal = RetVal & Chr(CInt(ByteArr(i))) Next i -------------------------------------------
...work just as well, or even better?
Doesn't... --------------------- dim var2() as String --------------------- ...create a array of strings?!?
And wouldn't... --------------------- Do while i <> max_number var2(i) = var1(i) loop --------------------- ...put every byte alone in each of these strings created?!?
Thanks Johs j!!! I think that could be the answer... ...how stupid of me!!!
I'll try it tomorrow!
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.