listview elements to a txt document

fifiddu70

Well-Known Member
Licensed User
Longtime User
How can I view the items included in a listview inside a txt file?
I'll post a sample code where I have not yet entered the code of the listview.
B4X:
Sub btnSalva_Click
    writer.Initialize(File.OpenOutput(File.DirRootExternal, "geripiz.rtf", True))
    writer.Initialize(File.OpenOutput(File.DirRootExternal, "geripiz.txt", True))
    writer.WriteLine("****************************************" & CRLF)

    writer.WriteLine("DATA: " & DateTime.Date(now) & " ORE: " & DateTime.Time(now) & CRLF )
    writer.WriteLine("OPERATORE: " & txtOperatore.Text   & CRLF)
    writer.WriteLine("ORDINE N�: " & txtOrdineN.Text   & CRLF)
    writer.WriteLine("OGGETTO�:  " & txtoggetto.Text & CRLF)
    writer.WriteLine("NOME�:  " & txtPersone.Text & CRLF)
    writer.WriterLine( listview ) ' what is the correct code to enter to view the items in the listview?
    writer.WriteLine("****************************************" & CRLF)
    
    writer.Close
    Msgbox ("SALVATAGGIO ESEGUITO CORRETTAMENTE DENTRO LA MEMORIA DEL TELEFONO CON NOME: GERIPIZ.TXT ED UN'ALTRO APRIBILE DA PC CON WORDPAD, CON NOME: GERIPIZ.rtf","AVVISO")
End Sub
help
 

klaus

Expert
Licensed User
Longtime User
This code should work:
B4X:
For i = 0 To ListView1.Size - 1
  writer.WriteLine(ListView1.GetItem(i) & CRLF)
Next
You must be aware that only the first label text is given, or you need to define a Return value with Addxxx2.

You should initialze the writer only once, you have two lines.

Best regards.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…