Attribute VB_Name = "Sauvergarde"
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 = Form1.Panneau.FixedRows To Form1.Panneau.Rows - 1
        Ligne = vbNullString
        For C = Form1.Panneau.FixedCols To Form1.Panneau.Cols - 1
            Ligne = Ligne & Form1.Panneau.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 = Form1.Panneau.FixedRows
    
    While Not FileStream.AtEndOfStream
        Ligne = FileStream.ReadLine
        tabLigne = Split(Ligne, Delimiter)
        C = Form1.Panneau.FixedCols
        For C = Form1.Panneau.FixedCols To Form1.Panneau.Cols - 1
            Form1.Panneau.TextMatrix(R, C) = tabLigne(C - Form1.Panneau.FixedCols)
        Next C
        R = R + 1
    Wend
    
    FileStream.Close
    Set FileStream = Nothing
End Sub
