Sauvegarder plusieurs groupes de contrôles dans un fichier texte

Résolu
Leo_Robotic_Passion Messages postés 135 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 2 décembre 2011 - 15 nov. 2007 à 20:16
Leo_Robotic_Passion Messages postés 135 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 2 décembre 2011 - 15 nov. 2007 à 21:38
Bonsoir a tous,
Je save et relis le contenue de 3 textbox de cette manière :

Dim NumFichier As Integer
Dim FichierTemp, FichierTemp2, FichierTemp3



Private Sub Form_Load()
    NumFichier = FreeFile
    Open App.Path & "\Config.txt" For Input As #NumFichier
    Line Input #NumFichier, FichierTemp
    TextBox1.Text = FichierTemp
    Line Input #NumFichier, FichierTemp2
    TextBox2.Text = FichierTemp2
    Line Input #NumFichier, FichierTemp3
    TextBox3.Text = FichierTemp3
    Close #NumFichier
End Sub



Private Sub Form_Unload(Cancel As Integer)
    NumFichier = FreeFile
    Open App.Path & "\Config.txt" For Output As #NumFichier
    Print #NumFichier, TextBox1.Text
    Print #NumFichier, TextBox2.Text
    Print #NumFichier, TextBox3.Text
Close #Fn
End Sub

J’aurais besoin de créer 3 groupes de 5 textbox comme ceci :
Groupe1 :


Text1(0), Text1(1), Text1(2), Text1(3), Text1(4).


Groupe2 :


Text2(0), Text2(1), Text2(2), Text2(3), Text2(4).


Groupe3 :


Text3(0), Text3(1), Text3(2), Text3(3), Text3(4).


Pourrait on me donner un exemple de comment sauver mes groupes dans un même fichier txt


Merci d’avance


Léo

2 réponses

Kristof_Koder Messages postés 918 Date d'inscription vendredi 3 août 2007 Statut Membre Dernière intervention 27 octobre 2008 10
15 nov. 2007 à 21:09
Voici le code pour un groupe, il suffira de dupliquer pourles autres :

Dim NumFichier As Integer
Dim FichierTemp, FichierTemp2, FichierTemp3

Private Sub Form_Load()
Dim i As Long

NumFichier = FreeFile
Open App.Path & "\Config.txt" For Input As #NumFichier
For i = 0 to 4
Line Input #NumFichier, FichierTemp
Text1(i).Text = FichierTemp
Next
Close #NumFichier
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim i As Long
NumFichier = FreeFile
Open App.Path & "\Config.txt" For Output As #NumFichier
For i = 0 To 4
Print #NumFichier, Text1(i).Text
Next
Close #NumFichier
End Sub
3
Leo_Robotic_Passion Messages postés 135 Date d'inscription dimanche 19 novembre 2000 Statut Membre Dernière intervention 2 décembre 2011
15 nov. 2007 à 21:38
Merci Kristof_Koder

Dim NumFichier As Integer
Dim FichierTemp, FichierTemp2, FichierTemp3
Dim i As Long 

Private Sub Form_Load()  
    NumFichier = FreeFile
    Open App.Path & "\Config.txt" For Input As #NumFichier
    For i = 0 To 4
        Line Input #NumFichier, FichierTemp
        Text1(i).Text = FichierTemp
         Line Input #NumFichier, FichierTemp2
        Text2(i).Text = FichierTemp2 
        Line Input #NumFichier, FichierTemp3
        Text3(i).Text = FichierTemp3 
    Next
    Close #NumFichier
End Sub

Private Sub Form_Unload(Cancel As Integer)  
    NumFichier = FreeFile
    Open App.Path & "\Config.txt" For Output As #NumFichier
    For i = 0 To 4
        Print #NumFichier, Text1(i).Text
        Print #NumFichier, Text2(i).Text
        Print #NumFichier, Text3(i).Text 
    Next
    Close #NumFichier
End Sub

Tous simplement ?
0
Rejoignez-nous