?
Solved

Convert String to Binary?

Posted on 2003-02-27
7
Medium Priority
?
3,701 Views
Last Modified: 2007-12-19
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
0
Comment
Question by:HanDuong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 3

Expert Comment

by:Gunsen
ID: 8040435
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.
0
 
LVL 7

Accepted Solution

by:
webJose earned 200 total points
ID: 8044910
You can try this:

Dim arrbData() as byte

arrbData = StrConv(text1.text, vbfromunicode)
0
 
LVL 7

Expert Comment

by:webJose
ID: 8045729
HanDoung, I am glad my answer helped, but why the grade of B?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:HanDuong
ID: 8045780
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, :-))
0
 
LVL 7

Expert Comment

by:webJose
ID: 8045804
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.
0
 

Author Comment

by:HanDuong
ID: 8045890
ok
0
 

Expert Comment

by:Banath
ID: 8046287
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
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question