vb.net - Match a string variable to the location in data file(specified column) so I can use all values in that row VB? -


The row that corresponds with, I want to assign the variables to the rest of the values ​​for that column. I've tried to find the match that I think:

  String as an integer for every straw in the dim intIndex (1) if Str.Contains (strID ) Then intIndex = Str INDexOf (strID, 0) end if next   

Even once I get the matching line number, how do I tell each variable, the row and column Ask to assign yourself?

The sample of one line and each column is divided by ",": 1234567,03 / 02 / 20137,2, B, L, ST and has unlimited rows

Go here - assuming that you already have an array of strings (probably readAllLines < / Code>), something like this should run in the right direction:

  Boolean as a rigid line = Incorrect dim row number as integer = 0 dim columns like str String (string) = "" like dim col1 "string =" "as a dim col2 string =" "string =" as dim col3 = "" "String = 7" as a stroke while the rowfound and not the row number   

Keep some things in mind:

First of all, I have not tested it, so there may be some syntax errors (I do more than VB.NET.)

Secondly, I used a loop That you do not waste time checking every line if you find the one you are looking for quickly while the loop leaves Interpretation If the flag line Forend equals is set to true or row number counting or array length (0-based index holds the array).

Inside the loop, it divides each row and recognizes the ID. If there is a match, then it populates the variable with column values ​​and sets the row. If there is no match, then this row increases the number number and appears on the next line (if any - if not, the loop gets out).

You may have to do some casting if you want to store values ​​in strings other than strings (your second column takes a date time).

Anyway, you should go in the right direction.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -