- Private Sub cmdEnregistrer_Click()
-
- Dim Fichier As String
-
- 'Le répertoire de l'application sera le repertoire initial du CommonDialog
- CommonDialog.InitDir = App.Path
- 'Affiche le contrôle CommonDialog pour enregistrer un fichier
- CommonDialog.ShowSave
- 'La variable fichier prendra le chemin du fichier sélectionné dans le CommonDialog
- Fichier = CommonDialog.FileName
-
- 'Si la variable fichier n'est pas vide on enregistre...
- If Fichier <> "" Then
- 'Lecture des 2 TextBoxs et écriture dans le fichier
- Open Fichier For Output As #1
- 'Écrit le texte dans le fichier.
- Print #1, txt1.Text 'La première ligne du fichier prendra le contenu du txt1
- Print #1, txt2.Text 'La deuxième ligne du fichier prendra le contenu du txt2
- Close #1 'Ferme le fichier.
- End If
-
- End Sub
-
- Private Sub cmdOuvrir_Click()
-
- Dim TextLine As String
- Dim Fichier As String
-
- 'Le répertoire de l'application sera le repertoire initial du CommonDialog
- CommonDialog.InitDir = App.Path
- 'Affiche le contrôle CommonDialog pour ouvrir un fichier
- CommonDialog.ShowOpen
- 'La variable fichier prendra le chemin du fichier sélectionné dans le CommonDialog
- Fichier = CommonDialog.FileName
-
- 'Si la variable fichier n'est pas vide on l'ouvre...
- If Fichier <> "" Then
- 'Lecture des fichiers et écriture du contenu dans les TextBoxs
- Open Fichier For Input As #1 'Ouvre le fichier."
- Line Input #1, TextLine 'Lecture de la 1ère ligne affectée au TextBox txt1
- txt1.Text = TextLine
- Line Input #1, TextLine 'Lecture de la 2ème ligne affectée au TextBox txt2
- txt2.Text = TextLine
- Close #1 'Ferme le fichier.
- End If
-
- End Sub
-
Private Sub cmdEnregistrer_Click()
Dim Fichier As String
'Le répertoire de l'application sera le repertoire initial du CommonDialog
CommonDialog.InitDir = App.Path
'Affiche le contrôle CommonDialog pour enregistrer un fichier
CommonDialog.ShowSave
'La variable fichier prendra le chemin du fichier sélectionné dans le CommonDialog
Fichier = CommonDialog.FileName
'Si la variable fichier n'est pas vide on enregistre...
If Fichier <> "" Then
'Lecture des 2 TextBoxs et écriture dans le fichier
Open Fichier For Output As #1
'Écrit le texte dans le fichier.
Print #1, txt1.Text 'La première ligne du fichier prendra le contenu du txt1
Print #1, txt2.Text 'La deuxième ligne du fichier prendra le contenu du txt2
Close #1 'Ferme le fichier.
End If
End Sub
Private Sub cmdOuvrir_Click()
Dim TextLine As String
Dim Fichier As String
'Le répertoire de l'application sera le repertoire initial du CommonDialog
CommonDialog.InitDir = App.Path
'Affiche le contrôle CommonDialog pour ouvrir un fichier
CommonDialog.ShowOpen
'La variable fichier prendra le chemin du fichier sélectionné dans le CommonDialog
Fichier = CommonDialog.FileName
'Si la variable fichier n'est pas vide on l'ouvre...
If Fichier <> "" Then
'Lecture des fichiers et écriture du contenu dans les TextBoxs
Open Fichier For Input As #1 'Ouvre le fichier."
Line Input #1, TextLine 'Lecture de la 1ère ligne affectée au TextBox txt1
txt1.Text = TextLine
Line Input #1, TextLine 'Lecture de la 2ème ligne affectée au TextBox txt2
txt2.Text = TextLine
Close #1 'Ferme le fichier.
End If
End Sub