Bytes conversion to string

Using an API Function and being returned array containing bytes

Example:

Expression      Value
szsize(0)        126
szsize(1)        88
szsize(2)        68
szsize(3)        65
szsize(4)        86
szsize(5)        48
szsize(6)        48
szsize(7)        50
szsize(8)        0

need to convert this into a string is there a function or if not an easy way to do this.
calisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deightonprogCommented:

sString = ""
for c = 0 to 8

 sString = sString & chr(szsize(0))

next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deightonprogCommented:
the 0 represents end of c type string, so maybe you coulds use

sString=""
i = 0
while szsize(i) <> 0
 sString = sString & chr(szsize(0))
 i = i + 1
wend
0
deightonprogCommented:
oops!!

sString=""
                      i = 0
                      while szsize(i) <> 0
                       sString = sString & chr(szsize(i))
                       i = i + 1
                      wend


                       
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

caraf_gCommented:
Quicker....

Dim arrDbl() As byte

ReDim arrDbl(2*LBound(szsize) to 2*UBound(szsize))

Dim lngCounter as long

for lngCounter = lbound(szsize) to ubound(szsize)
    arrDbl(2*lngcounter) = szsize(lngcounter)
next

Dim strResult as string
strResult = arrDbl
0
caraf_gCommented:
(just checking)
Option Explicit

Private Sub Command1_Click()

Dim arr1() As Byte

ReDim arr1(0 To 5)
arr1(0) = Asc("H")
arr1(1) = Asc("e")
arr1(2) = Asc("l")
arr1(3) = Asc("l")
arr1(4) = Asc("o")
arr1(5) = 0

Dim arr2() As Byte
ReDim arr2(2 * LBound(arr1) To 2 * UBound(arr1))

Dim lngCounter As Long

For lngCounter = LBound(arr1) To UBound(arr1)
    arr2(2 * lngCounter) = arr1(lngCounter)
Next

Dim strResult As String

strResult = arr2

MsgBox strResult
MsgBox Len(strResult)

End Sub



Yep, it works..
0
Erick37Commented:
Dim cArray(260) As Byte
Dim sString As String
Dim lVal As Long
lVal = SendMessage(Me.hwnd, WM_GETTEXT, 255&, cArray(0))

sString = StrConv(cArray, vbUnicode)
sString = Left(sString, lVal)
Debug.Print sString
0
Erick37Commented:
Or:

sString = StrConv(cArray, vbUnicode)
sString = Left(sString, InStr(1, sString, vbNullChar) - 1)
0
mcriderCommented:
calis,

Go with Erick37's implementation of StrConv... Much quicker!

Cheers!
0
caraf_gCommented:
Never even thought of that one <doh>
0
mcriderCommented:
caraf_g, alot of people forget about the string conversion and subclassing routines...


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.