Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Display only text conten of binary file


Sub  DisplayStrippedBinaryFile(X As String )
Dim temp As String , i As Long , temp2 As String , C As String , j As Long

Screen.MousePointer = vbHourglass

txtFileViewer.Text = " ... loading binary file  ...  please wait! "
DoEvents

Open X For Binary As #1
temp = Input (LOF(1), #1)
Close #1

For i = 1 To Len(temp)
       C = Mid $(temp, i, 1)
        Select Case C
            Case "A" To "Z" , "a" To "z" , "0" To "9" , " " , "."
               temp2 = temp2 & C
               j = j + 1
                If j Mod 50 = 0 Then
                   temp2 = temp2 & vbCrLf
                    DoEvents
                End If
       End Select
Next i

txtFileViewer.Text = "<binary file>" & vbCrLf & temp2

Screen.MousePointer = vbDefault
end Sub