VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "IniFile"
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private iflPath As String
Private IsOpen As Boolean
Private IsOpenToRead As Boolean
Private FileHandle As Long
Private iflEOF As Boolean

'Programed by ProGa (R) 2001
'E-mail: ProGa@ukrpost.net

Property Let path(ByVal strPath As String)
    
    If IsOpen Then Close #FileHandle
    iflPath = strPath
    
End Property

Property Get path() As String
    
    path = iflPath
    
End Property

Property Get FileEOF() As Boolean
    
    FileEOF = iflEOF
    
End Property

Private Sub Class_Initialize()
    
    iflPath = ""
    IsOpen = False
    FileHandle = 0
    IsOpenToRead = False
    
End Sub

Public Function OpenFile(Optional ByVal ToRead As Boolean = True) As Boolean
    
    On Error GoTo ErrHandler
    
    If IsOpen Then Close #FileHandle
    
    FileHandle = FreeFile
    If ToRead Then
        Open iflPath For Input As #FileHandle
        IsOpenToRead = True
        If EOF(FileHandle) Then iflEOF = True
    Else
        Open iflPath For Output As #FileHandle
        IsOpenToRead = False
    End If
    IsOpen = True
    
    OpenFile = True
    Exit Function

ErrHandler:
    OpenFile = False
    
End Function

Public Sub FileClose()
    
    If IsOpen Then Close #FileHandle
    
End Sub

Public Sub WriteNext(ByVal Value As Variant)
    
    If IsOpen And Not (IsOpenToRead) Then
        Value = CStr(Value)
        Print #FileHandle, Value
    End If
    
End Sub

Public Function ReadNext() As String
    
    Dim strTmp As String
        
    If IsOpen And IsOpenToRead Then
        Line Input #FileHandle, strTmp
        ReadNext = strTmp
        If EOF(FileHandle) Then iflEOF = True
    End If
        
End Function
