estica Posted February 12, 2016 at 12:27 AM Report Share #593379 Posted February 12, 2016 at 12:27 AM Amigos eu tenho uma ListView com um determinado conteúdo e grava tudo na boa... Mas se eu organizar por exemplo por ordem alfabética os itens já dá erro ao gravar... Dim File As System.IO.StreamWriter Dim P As Integer Dim S As String File = My.Computer.FileSystem.OpenTextFileWriter(Application.StartupPath & "\" & FileName, AppendTo) For P = 0 To Listview.Items.Count - 1 S = Listview.Items.Item(P).Text & "," & _ Listview.Items(P).SubItems(1).Text & "," & _ Listview.Items(P).SubItems(2).Text & "," & _ Listview.Items(P).SubItems(3).Text & "," & _ Listview.Items(P).SubItems(4).Text & "," & _ Listview.Items(P).SubItems(5).Text File.WriteLine(S) Next File.Close() Este é o método que uso para gravar... Agora a minha pergunta é... não seria melhor fazer reset do arquivo antes de gravar? E que dá me erro. Link to comment Share on other sites More sharing options...
He B TeMy Posted February 12, 2016 at 05:22 AM Report Share #593383 Posted February 12, 2016 at 05:22 AM For each item as ListviewItem in listview.items Dim values = string.empty for each subitem as listviewsubitem in item.subitems values += subitem.Text & "," next values += Environment.Newline 'para fazer a mudança de linha. File.AppendAllText(Application.StartupPath & "\" & FileName,values) Next Quando postares alguma pergunta em que te dê um erro no futuro, posta a mensagem do erro. 1 Report Link to comment Share on other sites More sharing options...
estica Posted February 13, 2016 at 11:30 AM Author Report Share #593445 Posted February 13, 2016 at 11:30 AM For each item as ListviewItem in listview.items Dim values = string.empty for each subitem as listviewsubitem in item.subitems values += subitem.Text & "," next values += Environment.Newline 'para fazer a mudança de linha. File.AppendAllText(Application.StartupPath & "\" & FileName,values) Next Quando postares alguma pergunta em que te dê um erro no futuro, posta a mensagem do erro. Ok amigo. Já resolvi o problema 😉 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now