difovelo
Messages postés13Date d'inscriptionlundi 9 mai 2005StatutMembreDernière intervention16 mai 2005
-
10 mai 2005 à 22:21
cs_EBArtSoft
Messages postés4525Date d'inscriptiondimanche 29 septembre 2002StatutModérateurDernière intervention22 avril 2019
-
11 mai 2005 à 08:55
Bonjour,
Je souhaiterais connaitre les écritures pour enregistrer un fichier, et celles pour ouvrir un fichier (ayant pour nom par ex "cotations").
Merci d'avance!
jpleroisse
Messages postés1788Date d'inscriptionmardi 7 novembre 2000StatutMembreDernière intervention11 mars 200627 11 mai 2005 à 00:00
Bonsoir,
Pour essayer cet exemple, place un contrôle TextBox (propriété multiligne à True) sur ta Form ainsi q'un CommandButton. Fait un copier/coller de ce code, tu verras que dans ton répertoire C:\ le fichier "cotations" sera créé et contiendra les données du textBox.
Avec le code dans la procédure Form_Load, dès que tu lance la Form le texte du fichier sera dans le textBox.(Tu peux placer le code dans un bouton de commande ou autre.
Private Sub Command1_Click()
Open "C:\cotations.txt" For Output As #1
Print #1, Text1.Text
Close #1
End
End Sub
Private Sub Form_Load()
Dim crlf,tout,texte
On Error Resume Next
crlf = Chr$(13) + Chr$(10)
Open "C:\cotations.txt" For Input As #1
Line Input #1, texte
tout = texte
If Len(tout) <> 0 Then
While Not EOF(1)
Line Input #1, texte
tout = tout + crlf + texte
Wend
End If
Text1.Text = tout
Close #1
End Sub
cs_EBArtSoft
Messages postés4525Date d'inscriptiondimanche 29 septembre 2002StatutModérateurDernière intervention22 avril 20199 11 mai 2005 à 08:55
Ouai ya aussi :
Dim Text As String
Function LoadText (ByVal FileName As String) As String
Open FileName For Binary As #1
LoadText = String (Lof(1),0)
Get #1, ,LoadText
Close #1
End Function
Sub SaveText(ByVal FileName As String,ByRef Data As String)
Open FileName For Binary As #1
Put #1, ,Data
Close #1
End Sub