vb.net - Combobox values from a textfile -


Hope people can help!

I am trying to create a composite box filled with information from a text file that has been used as a break mark. IE

Object, grade, N, word, 5, more text

I need different areas between integers / booleans / strings .. but I am getting this Code to work it properly

Ive searched the web, and found this code, but it is not working properly for me, maybe I was stupid but hope someone can help me Help me, oh guru of internet!

  The public sub-meritist () seems like Dim, as the new array list 'This call is required by the Windows Form Designer. I InitializeComponent () dim rdr IO.StreamReader = IO.File.OpenText (C: merits.txt ") while the rdr.EndOfStream dim line string = rdr.ReadLine () 'split the line by a comma as: dim array = row Get the right value: Breakdown is as follows: Merit name, type, shared, carthon, max, pre-rake dematname such as pus String = Arrest (0) Dim Martinep String = Array (1) Boolean = A dimension in the form of array list (2) String = Arrayial (3) Dimension as an empty meritmax = integer = array list (4 ) As the slow prereq string = array (5) cmoMRDro.Items.Add (new lookup (array list (0), sir list (1)), finally rrr.close () and sub  

4 things I will suggest.

  1. delimited / fixed width text Use TextFieldParser class reading foundation. They are more specific in this job and do not need to call the code already

  2. < Li>

    Create a structured / class to store your line items instead of raw changes, so you can get it in a more organized way.

  3. Use the list of that structure / class, instead of ArrayList

While whatever you are already doing, can be corrected with some modifications, I would have done it this way, keeping in mind all suggestions given above. So you can see how easy it is then:

  Structure Merit List Type Dematnam as an integer blurred meritize in the form of string retarded properties as the boolean dim carthon string dim Meritmeks as integer dim prereq string public all in as the new (data () as string) (as string) meritname = Integer.Parse (data (0)) merittype = data (1) Meritshared = boolean Purses (data (2)) Kartha = data (3) Meritmax = IntegerkParse data (4)) prereq = data (5) End Sub End Structure Public Sub Meritlist () new file type as a new file (merit list) as Dim tfp new FileIO.TextFieldParser ( "c: \ merits.txt") tfp.TextFieldType = FileIO FieldType.Delimited tfp.SetDelimiters ( ",") while not tfp.EndOfData FileData.Add (new MeritListType (tfp.ReadFields )) End while tfp.Close () '' You have a record in the file data '' whenever you want with it here sub  

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -