[RESOLVED] Dynamically populate listview from file?
Hello,
I am trying to figure out how to dynamically populate a listview with data from a file, except I only want specific lines and columns from that file. I have code right now that works to populate the listview from the file, but it writes the whole file and I only want specific lines and columns. Here is the code I currently have to populate the listview when the form loads:
VB 2010 Express Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("STFRWSAL.REP")
I copied the file's data to a .txt file and added it as an attachment becuase the original .REP file can only be opened with certain programs, but anyways I am trying to get the text that starts after the 4 digit number code up until the second identifiers (the B9, Bd, BX, and such) that start at the 34th space. I also want to ignore the fields that have no text directly after the 4 digit number code. I have tried different things with the delimiters, such as spaces and the second indentifiers, but it always either leaves something out or adds too much; plus it always has the number code and I do not want that. Is there maybe a way to set it to write only the text within the 5-33 positions and ignore fields that have no text in these positions? I need to load the list dynamically because the blank fields will not always be blank and the screens I am working on will need to reflect the changes. I know that there is way to do this with COBOL using multi editor because that is how the program I am working on was created originally, but I am supposed to be designing a more modern GUI and would really like to accomplish this with VB. Any help would be great.
Thanks a lot Paul. That was exactly what I was looking for and besides it working better than my code it was a lot shorter too. I gave you a good rating. Thanks again.