Par exemple:
Sub EnregistreCoord(ByVal nom As String, ByVal Point1 As Integer, ByVal Point2 As Integer)
Dim fp As Integer
Dim Fichier As String
fp = Freefile
Ficher = "C:\MonDossier\ini\Coord.ini"
On Error Resume Next
Open Fichier For Append As #fp
Print #fp, nom & ", " & Point1 & ", " Point2
Close #fp
If Err.Number <> 0 Then
MsgBox Err.Number & " : " & Err.Description, VbCritical,"ERREUR"
Exit Sub
Else
MsgBox "Les données ont été enregistrées."
End If
End Sub
Ensuite, pour lire par exemple, on stocke les données en mémoire dans une structure
Private Type TabCoord
nom As String
point1 As Integer
point2 As Integer
End Type
Public Tcoord() As TabCoord
Public ind As Long
Sub lireCoord()
Dim fp As Integer
Dim Fichier As String
Dim str As String
Dim tTab()
fp = FreeFile
Ficher = "C:\MonDossier\ini\Coord.ini"
On Error Resume Next
Open Fichier For Input As #fp
While Not EOF(fp)
Line Input #fp, str
tTab = Split(str, ",")
ReDim Preserve Tcoord(ind)
Tcoord(ind).nom = tTab(0)
Tcoord(ind).point1 = tTab(1)
Tcoord(ind).point2 = tTab(2)
ind = ind + 1
Wend
Close #fp
If Err.Number <> 0 Then
MsgBox Err.Number & " : " & Err.Description, VbCritical,"ERREUR
Exit Sub
Else
MsgBox "Les données ont été récupérées"
End If
End Sub
;o)
«Ce que l'on conçoit bien s'énonce clairement, Et les mots pour le dire arrivent aisément.»
Nicolas Boileau
Comment fais-t-on pour enregistrer des points dans un fichier texte et les récupérer ensuite: c'est justement cela ma question!
Merci de t'intéresser à mon problème.