Advanced Programming | | Notes on Visual Basic .NET Console Application:
Visual Basic .NET project writen using Console Application : As we start programming, we will design, write code, and run programs at first in the Console environment. The Console Application runs in a text environment only. The Console Application project template adds the necessary items needed to create a console application. Console applications are typically designed without a graphical user interface and are compiled into a stand-alone executable file. A console application is run from the command line with input and output information being exchanged between the command prompt and the running application. Because information can be written to and read from the console window, this makes the console application a great way to learn new programming techniques without having to be concerned with the user interface. This allows us to focus on the code first. After Unit 2, we will then apply forms for object-oriented programming. In addition, you will see newer methods (not seen before) and you must be prepared to rethink and apply these new methods.

A review of the Visual Basic indow components: When working with this IDE, you will be using and interacting with four different windows set around and below this environment (solution explorer, properties, and the tool box). Instead of the Minimize button, these windows have Pin buttons that allow you to pin and minimize the window to the side of the window environment. For the most part, try to keep all windows open and pinned-up.

The Module Window: You will see that there will be a Start tab window and a Module tab window. The Module tab window is the window that you will use to program and code. Below the tabs you should also see the object box and the procedure box. One new feature that this code window has is expanding and collapsing plus and minus signs beside the code. The plus sign indicates the code is collapsed and the minus sign indicates that the code is expanded. This allows the designer to collapse lines of the code at any time.

Building and running your Visual Basic Console Application: Through the Console application, before you run your program you should select Build from the menu and then Build “file name”. This process will read each line and test the program. If you have errors, it will find and locate the lines which contain the errors. To run the program you must select Debug from the menu and then Start or just press F5.

As a review here are some information to recap from the Progrmaming class and which you will need to know and understand before you start programming.

Remarks - a single quote (') - This is used to include explanatory remarks in a program. As you can see in the above program; they are used in the FlowerBox as well as within the program. It is good programming practice to begin all procedures and functions with a brief comment describing the functional characteristics of the procedure (what it does), for your own benefit and the benefit of anyone else who examines the code.

The Dim statement - Used at module, class, structure, procedure, or block level to declare and allocate storage space for variables. More information is to come with the DIM statement.

As String - The String class of the .NET framework provides many built-in methods to facilitate the comparison and manipulation of strings. It is now a trivial matter to get data about a string, or to create new strings by manipulating current strings. The Visual Basic .NET language also has inherent methods that duplicate many of these functionalities.

As Integer - Integer variables are stored as strigned 32-bit (4-byte) integers ranging in value from -2,147,483,648 through 2,147,483,647. The Integer data type provides optimal performance on a 32-bit processor, as the smaller integer types are slower to load and store from and to memory. Note The Integer data type can be converted to the Long, Single, Double, or Decimal data type without encountering a System.OverflowException error.

Console.Write() Functions - Unlike the Print function, the Write function inserts commas between items and quotation marks around strings as they are written to the file. When Write is used to write data to a file, only the following data formats are supported several universal assumptions are followed so the data can always be read and correctly interpreted using Input, regardless of locale:

Console.WriteLine() Functions - WriteLine inserts a newline character (that is, a carriage return–linefeed, or Chr(13) + Chr(10)), after it has written the final character in Output to the file.

Console.ReadLine() Functions - In short, the Console.Read holds the console application window until the user presses a keyboard button. This is used to hold the console window for the user to read and apply input to the program.

Printing in Visual Basic with the Console Applications: Using the console application, you must print the code through the code window by selecting File and then Print. To print the output during run time you will use the paint program. So you will have two different print outs that should be turned in (code and output).

To print the output during runtime you will first need to run the console application use the Snipping Toll to capturer the output. You will then need to open the print program and paste the information from the click border by selecting Edit menu and Paste. You should then see the output as an image/picture. Change the attributes or better known as inverting the color through the Image menu (this will make the letters black and the background white) and resize if needed. Then just select File and Print in the Paint program to print the run time information.

Learn it online: Not only will you complete assignments from the class textbook and course web site, you will also learn through on-line websites. There will be times that you will need to use the Internet Explorer, to search for topics.

Adv. Programming - Day 3 Example Problem #1 Simulation:

Example #1 Simulation (The Basic Visual Basic .NET Console Application): – Below is a simple example of a Visual Basic console program where there is a conversion from Fahrenheit Temperature to Celsius Temperature. Notice and review the flower box, comment lines, and the VB .NET code. This shows some of the basic keywords that you will use to create and build programs in the VB .NET console applications. Try to copy this code to the Visual Basic .Net Console application and run the program.

Flowerbox template:
  [ Flower Box ]

Teacher's Comments: You are asked to complete the example problem above and print out both the program code and the console application screen during run time, to be turned in together. Try to save all work to your disk. Understanding all of the code lines is important as we move forward with Visual Basic .NET.


Directions for turning in Example problem - In the classroom: No Printing just upload the assignment files to Canvas Module 1 Example Problem 1. You will NOT need to print out any documents just submit this example problem in the Canvas drop box. Note you should have two screen shots: Example 1 code and the console output screen. Put all screen shots (images) in a Word Document and send me the file. Save the Word document as the example problem: Example Problem 1. Please note, that you will need to re-save this file as a pdf file before uploading. Here is an example video on how to do that: See Video > > >     How to save a Word file to a pdf   right click mouse and select... (Open link in new tab)