Click here to Skip to main content
13,596,956 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to go back to previous line. For example currently i am reading the "line5:" in below case, agian i want to start the reading from "Line 2:". I have a question like how to go back to line 2.

Line 1: --- To do something----
Line 2: --- To do something----
Line 3: --- To do something----
Line 4: --- To do something----
Line 5: --- To do something----
Line 6: --- To do something----
Line 7: --- To do something----
Posted 21-Feb-13 0:27am
CHill60 21-Feb-13 6:36am
Your question needs clarifying. Try using the Improve question link to add some detail - for example post the code that you are using to read the file

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If the files that will be read are not extra large files and are delimited by CRLF, you can use the ReadAllText method to read the entire file into a string and Strings.Split to create an array of Type String where each element of the array is a row of the file.
Dim arrFileContents() As String = Strings.Split( _
     My.Computer.FileSystem.ReadAllText( _
     "C:\bat\RestoreSQL.log"), vbCrLf)

Dim intMaxIndex as Integer = arrFileContents.GetUpperBound(0) ' The highest index of the array
Dim intFileRows as Integer = arrFileContents.GetUpperBound(0) + 1 ' The number of rows in the file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02-2016 | 2.8.180621.3 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100