|
-
February 8th, 2000, 07:19 AM
#1
Convert a Binary File To Ascii String
Dear All:
I have a problem on converting a binary file to a Ascii String.
The following is a sub to convert an input binary String to ascii string but I found that
it does not working
Can someone point out where did I do wrong???
Thanks in advance
public Sub Bin2Asc(strBin as string, strAsc as string)
Dim lLen as Long, i as Long, strBin2 as string
lLen = len(strBin)
strAsc = ""
for i = 1 to lLen
Dim strTmp as string
Dim btByte as Byte
strTmp = Hex(Asc(mid$(strBin, i, 1)))
If len(strTmp) < 2 then
strTmp = "0" & strTmp
else
If len(strTmp) = 4 then
lLen = lLen - 1
End If
strAsc = strAsc + strTmp
If i = lLen then
Exit for
End If
next i
End Sub
-
February 8th, 2000, 11:10 AM
#2
Re: Convert a Binary File To Ascii String
what you did wrong was that you used a ASCII->Binary function to convert Binary-> ASCII. The name of the function should have been Asc2Bin, because this will take any string and convert it to another string double the size containing the hex codes of all the chars.
-
February 8th, 2000, 08:30 PM
#3
Re: Convert a Binary File To Ascii String
Whoops!
Sorry about the naming problem, this sub should call Asc2Bin.
Assume I have a text file contain the follow hex value
30 80 2A 86 48 86 F7 0D 01
^^^^^^^^^^^
This sub will read all the hex value one by one collectly except it will read 2 byte at once for the &H8648 and &H86F7.
I tried to use other conversion function like AscB.. etc, but they just doesn't work.
Can someone give me a hint?
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|