Hello,
have this text file with exactly 100 lines, counted.
I sucessfully load it to a multiline textbox. That's not the problem
I want to loop through the lines and write just lines 1 through 10 or
in code, 0 to 9.
My controls:
textbox that contains 100 lines: ti
This is my current code:
For linecount = 9 To 0
Dim linetext As String = ti.Lines(linecount)
Dim sw As New IO.StreamWriter("C:\top10.txt")
Dim skipLine As Integer = linecount + 1
For skipLine = skipLine To 0
sw.WriteLine(sw.NewLine)
Next
sw.WriteLine(linetext)
sw.Close()
Next
it sucessfully writes line ten on text file's line 23.
this is the result:
start:::::::::
10 | Hillsborough* | Tampa | Fla. | 5.085 | 50
end::::::::::
but this is what I need:
1 | Jefferson County* | Irondale | Ala. | 10.755 | 2
2 | International Academy*|Bloomfield Hills|Mich.|8.422 |0
3 | Stanton College Prep* | Jacksonville | Fla. | 7.385 | 7.8
4 | Eastside* | Gainesville | Fla. | 6.682 | 39
5 | H-B Woodlawn | Arlington | Va. | 5.747 | 14
6 | Science/Engineering Magnet |Dallas|Texas|5.545|37.8
7 | Paxon* | Jacksonville | Fla. | 5.373 | 13
8 | Pensacola* | Pensacola | Fla. | 5.362 | 63
9 | Raleigh Charter | Raleigh | N.C. | 5.089 | 0
10 | Hillsborough* | Tampa | Fla. | 5.085 | 50
please disregard the facts and just imagine as line1... line2... line 3... and so forth.
I am trying to put all these into an Excel, but it's one line, and Excel
just puts them on 1 column, 100 rows so it's not useful......
Anyways, again, the need is what I need and the result is the resulting text
file from the provided code...
this is my first time dealing with these codes (or For loops) so I am not very
experienced. A good start for me will do enough. Let alone, a provided
code will be great!
Thank You!
Keehun Nam

String Minipulation... Pretty easy...
pavvu_kk
*grin* glad to help. Like I said, I think step 1 is what you get if you don't specify it, so in this case, you could drop the step, because you're specifying what you get for free, anyhow.
JeffsMSDNUserID
I rewrote just using 4 lines...!!!:
Dim number As Integer
For number = 0 To 9 Step 1
sw.WriteLine(ti.Lines(number))
Next
thanks for your help!
I was missing the step!
Thanks!
Keehun Nam
Joel Joines
For linecount = 9 To 0
I believe if you want to step by anything other than 1 you need to say so, as in
For linecount = 9 to 0 step -1
But that's going from memory, I don't do VB.