OVH Cloud OVH Cloud

sauvegarder le contenu d'un listebox dans un txt

2 réponses
Avatar
Pascal
bonjour
j'ai essayé avec fileopen :

'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "\" & "a.txt",
OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
peut -on le faire avec WriteAllText ? : j'ai essayé

Dim i As Short

For i = 0 To lstInputWord.Items.Count - 1

LaListe.SelectedIndex = i

My.Computer.FileSystem.WriteAllText(.FileName, LaListe.SelectedItem +
Environment.NewLine, True, System.Text.Encoding.Default)

Next

mais ça merdouille la liste n'est pas conservé...

merci de votre aide

http://www.scalpa.info

2 réponses

Avatar
scalpa
essaie :
If .ShowDialog() = Windows.Forms.DialogResult.OK Then

Dim w As IO.StreamWriter

Dim i As Integer

w = New IO.StreamWriter(.FileName)

For i = 0 To lstInputWord.Items.Count - 1

w.WriteLine(lstInputWord.Items.Item(i))

Next

w.Close()

End If




"Pascal" a écrit dans le message de news:
44722450$0$28223$
bonjour
j'ai essayé avec fileopen :

'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "" & "a.txt",
OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
peut -on le faire avec WriteAllText ? : j'ai essayé

Dim i As Short

For i = 0 To lstInputWord.Items.Count - 1

LaListe.SelectedIndex = i

My.Computer.FileSystem.WriteAllText(.FileName, LaListe.SelectedItem +
Environment.NewLine, True, System.Text.Encoding.Default)

Next

mais ça merdouille la liste n'est pas conservé...

merci de votre aide

http://www.scalpa.info



Avatar
Pascal
--
bonjour

merci c'est ça...
http://www.scalpa.info