This code works fine except it does not pick up the last word at the end of the line. The text file it reads, words are seperated by tabs. When running this code it picks up every word except for the last and chucks it in the array, any ideas to find out how to get the last word placed in the array.
Thanks, Schoolproject.
Code:Do Until strStudent Is Nothing ' this will run through the read line function until it finds the end of the whole file itself For j = 1 To Len(strStudent) ' this will read through the entire line itself ochar = Mid(strStudent, j, 1) ' ochar is used as a single character in the file, command mid reads strstudent, j letter and reads one character ostring = ostring + ochar ' builds the string by adding characters to ostring If ochar = Chr(9) Then ' if the program finds a tab ofield = ofield + 1 ' changes where about the program chucks the data into the array codes(ocount, ofield) = Mid( _ ostring, 1, Len(ostring) - 1) ' chucking the data into the array ostring = "" ' setting the ostring back to null MsgBox(codes(ocount, ofield)) End If Next j ' next tab in the line codes(ocount, 0) = ocount ' moves the array so that the program doesn't overwrite the data that was just entered ocount = ocount + 1 ' goes up by one, by the end of creating the array you will have x amount of rows strStudent = objFile1.ReadLine() ' reading the file ostring = "" ' setting ostring as null ofield = 0 ' setting ofield as null Loop




Reply With Quote
