VB Code:
  1. Public Function GetLineCount(Byval Filename As String) As Long
  2.    Return New IO.StringReader("C:\MyTextFile.txt").ReadToEnd.Split(vbNewLine).GetUpperBound(0) + 1
  3. End Function
Note that this doesn't check that the file exists, make sure it does before calling the function.