Getting integer error in vb2013

What does the code has wrong that gives "cannot convert" error (we are working vb2013).
rayluvsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rayluvsAuthor Commented:
sorry about here is the code:

        Dim TotalLines As Integer
        TotalLines = 0
        Dim vPath As String = "C:\filename.txt"
        Using reader As New System.IO.StreamReader(vPath)
            While Not reader.EndOfStream
                TotalLines = TotalLines + 1
            End While
            lblResults = TotalLines
        End Using
        MsgBox("Done!")
        Me.Close()

Open in new window


Here is the error:
Error 1 Value of type 'Integer' cannot be converted to 'System.Windows.Controls.Label'.      

Looks like is the line " lblResults = TotalLines"
0
Paul JacksonSoftware EngineerCommented:
try:

lblResults.Text = TotalLines
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rayluvsAuthor Commented:
Oh god yes!  We are starting in vb2013 and forgot this.

Prior closing the question, can you see the code for another error that just happened:

I have a text file with 3 lines to test the code.  But when running it keeps running past 3 lines, like there is no end.

The line "While Not reader.EndOfStream" suppose to stop ate 3 lines read?

Anything missing?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

käµfm³d 👽Commented:
You're not actually reading any lines in your loop. You need a call to ReadLine or similar.
0
rayluvsAuthor Commented:
Isn't "While Not reader.EndOfStream" the line reader?
0
Paul JacksonSoftware EngineerCommented:
.EndOfStream is a property that tests whether you have reached the endofstream you need to call the Readline method to actually read in the data :

While Not reader.EndOfStream
                 reader.readline()
                TotalLines = TotalLines + 1
            End While
0
rayluvsAuthor Commented:
OK
0
rayluvsAuthor Commented:
Just checked and yes it was missing, thanx!
0
rayluvsAuthor Commented:
Thanx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.