Link to home
Start Free TrialLog in
Avatar of HanDuong
HanDuong

asked on

Convert String to Binary?

Hi All,
This is the code to convert the string to binary buffer:
    Dim nLen As Double
    nLen = Len(Text1.Text)
    ReDim bytA(nLen)
    For i = 1 To nLen
       bytA(i - 1) = CByte(Asc(Mid(Text1.Text, i, 1)))
    Next

My question is:
-If nLen is large (about > 2M), this code takes a lot of time, how to improve this code.
-Is there the other codes or functions to convert?

Thanks in advance,
Minh
Avatar of Gunsen
Gunsen

Well since you do not modify the string, the string itself is an binary buffer.
Open "file.dat" For Random As #1
Print #1, text1.text
Close #1
Would hold the binary data only.
ASKER CERTIFIED SOLUTION
Avatar of webJose
webJose

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
HanDoung, I am glad my answer helped, but why the grade of B?
Avatar of HanDuong

ASKER

I think your answer is good and select good grade, i don't think this is not enough for you, sorry.... if have a next time you will have grade of A, :-))
Fine, I'll ask the moderators to change the grade as you do not have any solid reason for denying the A grade.  Hopefully, they will comply in a few days.
ok
HanDuong- The normal grade to give for a good answer is A. Only give a B when the answer did not give you the solution, but still helps you find the solution. Thanks.

Grade changed to A, per request and agreement from HanDuong.

Banath
EE Moderator