I\'m new to programming and decided to take VB.net up as my first language, I\'m quite new and I\'m currently trying to write a sorting program. I\'m trying to load in a file, s
Using currentfilereader As StreamReader = New StreamReader("S:\class" & CName & ".rtf")
Do
line = currentfilereader.ReadLine
If IsNumeric(line) AndAlso CInt(line) >= 1 AndAlso CInt(line)<= 10 Then
list.Add(line)
Console.WriteLine(line)
End If
Loop Until currentfilereader.EndOfStream
End Using
Since it seems all you are wanting is values 0 - 10, you can convert line to an integer and check if it is within that range.
AndAlso is a short-circuited comparison, meaning that as soon as one of your values is False, it'll stop comparing and carry on.
Also, you should make sure your readers end when they find EndOfStream, rather than when your line is Nothing.