Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

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

Determine if file is binary


Function  IsBinary() As Boolean
Dim i As Long , Char As String * 1, j As Long
Open MergePathData(lstFiles.Path, lstFiles.List(lstFiles.ListIndex)) For Binary As #1
IsBinary = False
If LOF(1) > 0 Then
   j = 10
    If LOF(1) < j Then j = LOF(1)
    For i = 1 To j
        Get #1, i, Char
        Select Case Asc ( Char )
            Case 9, 10, 13
                'accept TAB, vbCRLF. no action
            Case 0 To 31, 128 To 255
               IsBinary = True
                Exit For
       End Select
    Next i
End If
Close #1
end Function