Attribute VB_Name = "Module1"
Private Const FileName As String = "Données.don"
Private Const Delimiter As String = "$$"
Private fs As New FileSystemObject

Public Sub Enregistrer()
    
    
    Dim FileStream As TextStream
    Dim FilePath As String
    Dim Ligne As String
    Dim R As Long
    Dim C As Long
    
        
    FilePath = App.path & "\" & FileName
    Set FileStream = fs.OpenTextFile(FilePath, ForWriting, True)
    
    For R = Flex.Grille.FixedRows To Flex.Grille.Rows - 1
        Ligne = vbNullString
        For C = Flex.Grille.FixedCols To Flex.Grille.Cols - 1
            Ligne = Ligne & Flex.Grille.TextMatrix(R, C) & Delimiter
        Next C
        Ligne = Left(Ligne, Len(Ligne) - Len(Delimiter))
        FileStream.WriteLine Ligne
    Next R
    
    FileStream.Close
    Set FileStream = Nothing
    Set fs = Nothing

End Sub

Public Sub Charger()
    
    Dim FileStream As TextStream
    Dim FilePath As String
    Dim Ligne As String
    Dim tabLigne() As String
    Dim R As Long
    Dim C As Long
    
    FilePath = App.path & "\" & FileName
    Set FileStream = fs.OpenTextFile(FilePath, ForReading, False)
    
    R = Flex.Grille.FixedRows
    
        
    While Not FileStream.AtEndOfStream
        Ligne = FileStream.ReadLine
        tabLigne = Split(Ligne, Delimiter)
        C = Flex.Grille.FixedCols
        For C = Flex.Grille.FixedCols To Flex.Grille.Cols - 1
            Flex.Grille.TextMatrix(R, C) = tabLigne(C - Flex.Grille.FixedCols)
        Next C
        R = R + 1
    Wend
    
    FileStream.Close
    Set FileStream = Nothing

End Sub
