cbnet
Messages postés176Date d'inscriptionvendredi 29 octobre 2004StatutMembreDernière intervention 7 mars 2005 8 févr. 2005 à 18:16
Bon, dsl mais comme je t'ai dit je n'ai pas vb.net, apparemment le .net
utilise une autre fonction pour acceder au fichier (regarde les
fonctions FileSystem !) :
Donc a l'aveuglette je te propose ceci (ta lisbox s'appelle List1) :
Dim MonFichier As String, Ligne As String, i As Integer, ff As Integer
Sinon, regarde cette page, elle est en anglais mais le gars en question
a exactement le meme probleme que toi et en .net, et tu verras en plus
les fonctions pour lire et ecrire sur un fichier :
cbnet
Messages postés176Date d'inscriptionvendredi 29 octobre 2004StatutMembreDernière intervention 7 mars 2005 9 févr. 2005 à 01:04
Mais je suis pas trop sur de comprendre ton problème... Mais le
principe est là : chaque ligne de ta listbox a un index, pour pouvoir
l'enregistrer il faut que tu fasses une boucle avec un compteur qui va
aller du premier index au dernier. Mais si ton problème c'est écrire
dans un fichier, je te l'ai dit il faut que tu regardes les fonctions
de l'objet FileSystem, par exemple tapes FileSystem suivi d'un point et
tu verras la liste des propriétés et des fonctions de cet objet.
Sinon cherches éventuellement sur Google "FileSystem.FileOpen" et tu trouveras surement des exemples à ta question...
Ce que je ne comprends pas non plus, le gars a exactement le meme
problème que toi, et il a résolu son problème, t'es allé voir la page ??
Ben sinon désolé comme je t'ai dit le .net c'est pas ma tasse de thé...
cbnet
Messages postés176Date d'inscriptionvendredi 29 octobre 2004StatutMembreDernière intervention 7 mars 2005 9 févr. 2005 à 01:09
Knowing that,
all you need to do is step through the contents of your listbox with a
loop and print each line to a file. In order to do this, use the above
mentioned FileSystem inherent in vb.net. There are some syntax
trickeries here.
* FileSystem.FileOpen( : filenumber, path, openmode)</gras> * This will open an existing file or create a new one if one does not exist. : <dt>filenumber - An integer value that will be the designation of the file for read/write operations. * : path - The full path to the file, including the complete filename and extension. * : openmode - a constant representing the method to access the file (input, output, append, binary, etc...) * After you have opened the file, use FileSystem.PrintLine( : filenumber, value)</gras> command to write to the file. * This will write whatever : value is to the next line of the file. * When you are done writing to the file, close it with FileSystem.FileClose( : filenumber)</gras>.<dt>You
now have a file on the drive with the data that you wrote to it. You
can open it in notepad to see what it looks like, and you may have to
do some testing to get it just right.
To read from the file is very similar, open it with FileSystem.FileOpen, but set the mode to input and use FileSystem.LineInput(FileNumber) to get each line of information. Again, make sure you test this a
lot so you can get it just right. Each time you use the LineInput function, it will input one line from the file, so you may have to check against the FileSystem.EOF(FileNumber) property to see if you've reached the end of the file. Also, LineInput
is a function, so you will have to set it against a string variable: as
in varString = FileSystem.LineInput(FileNumber).