Advertisement
Guest User

KalEl

a guest
Mar 4th, 2010
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.66 KB | None | 0 0
  1. ' This can be used to transform binary file to (and from) text file
  2.  
  3. Const HexDigits$ = "0123456789ABCDEF"
  4.  
  5. Function ToHex$(strin$)
  6.     a% = AscB(c)
  7.     a1% = Int(a / 16): a2% = a Mod 16
  8.     ToHex$ = Mid(HexDigits, a1 + 1, 1) + Mid(HexDigits, a2 + 1, 1)
  9. End Function
  10.  
  11. Sub Bin2Hex(Infile$, Outfile$)
  12.     f% = FreeFile
  13.     Open Infile For Binary Access Read As #f%
  14.     fo% = FreeFile
  15.     Open Outfile For Output Access Write As #fo%
  16.     cnt& = 0
  17.     While Not EOF(f%)
  18.         cnt = cnt + 1
  19.         ch$ = " "
  20.         Get #f%, , ch$
  21.         If Not EOF(f%) Then
  22.             Print #fo%, ToHex(ch);
  23.         End If
  24.     Wend
  25.     Close f%
  26.     Close fo%
  27. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement