I have tried all the methods available to convert byte () to string and vice versa in VBSCRIPT.
Expand|Select|Wrap|Line Numbers
- Function ByteArray2Text(varByteArray)
- Dim rs
- Const adLongVarChar = 201
- Set rs = CreateObject("ADODB.Recordset")
- rs.Fields.Append "temp", adLongVarChar, LenB(varByteArray)
- rs.Open
- rs.AddNew
- rs("temp").AppendChunk varByteArray
- rs.Update ByteArray2Text = rs("temp")
- rs.Close
- Set rs = Nothing
- End Function
- Function ByteArray2Text(varByteArray)
- Dim byt
- Const adTypeText = 2
- Const adTypeBinary = 1
- Set byt = CreateObject("ADODB.Stream")
- byt.Type = adTypeBinary
- byt.Open
- byt.Write varByteArray
- byt.Position = 0
- byt.Type = adTypeText
- byt.CharSet = "us-ascii"
- ByteArray2Text = byt.ReadText
- byt.Close Set byt = Nothing
- End Function
- Function ByteArray2Text(varByteArray)
- 'Convert byte array into a string with VBScript
- '60kb = 2 seconds, 100kb = 5 seconds, 200kb = 25 seconds
- Dim strBuffer, lngCounter
- strData = ""
- strBuffer = ""
- For lngCounter = 0 to UBound(varByteArray)
- strBuffer = strBuffer & Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
- 'Keep strBuffer at 1k bytes maximum
- If lngCounter Mod 1000 = 0 Then
- strData = strData & strBuffer
- strBuffer = ""
- End If
- Next ByteArray2Text = strData & strBuffer
- End Function
In all these methods i get microsoft V B script runtime error - Object doesnt support this type or method. some body please help me out