hi i am using winforms in vb.net .. i have this for loop which is below basically i am reading the firstline from a textfile there are empty spaces between the text it is returning therefor everywhere, where there is a space i am adding a number.
this is working fine but for some reason after reading the last string which the textfile the for loop keeps on going and adding another extra column for me . can someone tell me how i can make the for loop to stop as soon as it at the end of the first line where there is the last string..
thanks in advance
this is working fine but for some reason after reading the last string which the textfile the for loop keeps on going and adding another extra column for me . can someone tell me how i can make the for loop to stop as soon as it at the end of the first line where there is the last string..
thanks in advance
Code:
Dim oSR As New StreamReader(strFilePath)
GO TO THE TOP OF THE FILE AND GET THE BEGIN
oSR.BaseStream.Seek(0, SeekOrigin.Begin)
ADD THE HEADER COLUMNS TO THE DATSET
Dim strFieldss As String
For Each strFields In oSR.ReadLine().Split(strdelimeter)
If strFields = "" Then
strFields = i
End If
i = i + 1
oDT.Columns.Add(strFields)
Next