Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Content Obsolete

This content is no longer current. We recommend you try the following url for more up to date content: http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

While Iterations and Reading Data from a Text File - 11

Download

Right click “Save as…”

In this lesson we'll both learn a new type of iteration statement (While) and will learn how to utilize the StreamReader class to stream data from a file to the Console window. Additionally, we'll learn how to add new files to our project, how to set properties of our file using the Properties window, how to add a using statement as a means of resolving a class name referenced in our code to the namespace in which it is defined, and more.

Download the source code for While Iterations and Reading....

Tag:

Follow the Discussion

  • karimkarim

    Always great BOB
    very intuitive, nice explanation
    wishes from Morocco

  • Golnazgolnazal HEY HEY HEY

    open.

  • harryharry

    G'day Bob,
    (btw - enjoying the vid's - going to be excellent resources for my students)

    Would it have been "better" (more obvious) to use a "do until IsNothing(line) ... loop" construct rather than the "while ... end while" ? Or perhaps even the "do ... loop until IsNothing(line)" ?

    The "benefit" would be the immediate removal of the "double-negative", which, to be honest, as a vet of 4 decades of coding still trips me up occasionally ;') I know my students struggled with it just last week, hence why it is still "fresh" in my mind :)

    Kind regards,

    Harry

  • @harry:  Great, great tip!  You're right, I probably could have written than using a different looping structure and made it a "positive" rather than a double-negative.  Smiley  Thank you and best wishes to your students!

  • RickRick

    I have noticed that with Harry's Do until method you no longer need the If then statement also.. Thanks for the tip Harry and thanks Bob for the While method I see where they can both be very useful.

  • I was looking for an open thread to thank you on previous 10 tutorials but all threads were closed....finally got the opportunity ...Thanks for creating tutorials that are so simple yet teaches you a lot...are there videos for WinForms apps too using VB..if yes plz share the link..I'll be very grateful to you..well that is already I'm.

  • BethBeth

    Thank you for these great videos! Bob - your delivery is excellent. Great voice, cadence, inflection, etc. Of course it helps that the subject matter is important to me, but that's beside the point!

  • Thank you for this excellent series, a great resource.

  • Kent HaunschildKent Haunschild

    Tried Harry's method the Do Until...Loop
    coded like this:
    Dim myReader As StreamReader = New StreamReader("values.txt")

    Dim line As String = ""
    Do Until IsNothing(line)
    line = myReader.ReadLine()
    Console.WriteLine(line)
    Loop

    myReader.Close()
    Console.ReadLine()
    The program ran I.E. gave the correct output to the display, but with following errors:

    A first chance exception of type 'System.IndexOutOfRangeException' occurred in UnderstandingArrays.exe
    A first chance exception of type 'System.IndexOutOfRangeException' occurred in UnderstandingArrays.exe
    A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

    I realize the lesson was on using the While()...IsNothing but as wondering what else is wrong with my code.

  • @Rick: Agreed.

    @ZeroShek:  Thanks!  I'm sure there are videos out there, but not by me.  Sorry!

    @Beth: Ah, thanks Beth!

    @meldoc: Thank you!

    @Kent Haunschild: Hi!  check this out ... it uses Do ... Loop Until properly:

    http://msdn.microsoft.com/en-us/library/aa720461(v=vs.71).aspx

  • juebanjueban

    so good!

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.