'--------------------------------------------------------
'  関数名 : GetFileCount
'  用途  : テキストファイルの行数を取得
'  引数  : FilePath - ファイルのパス
'  戻り値 : ファイルの行数
'  備考  : エラーが起きると-1が戻ってくる
Function GetFileCount(FilePath As String) As Integer
Dim FF As Long
Dim intC As Integer
Dim strBuff As String

On Error GoTo ErrHandler
intC = 0
    FF = FreeFile
    Open FilePath For Input As #FF
        Do Until EOF(FF)
            Line Input #FF, strBuff
            DoEvents
            intC = intC + 1
        Loop
    Close #FF
    GetFileCount = intC
    Exit Function
    ErrHandler:
    GetFileCount = -1
End Function