IT 236 -- 6/15/06

To Notes

Lecture Summary for IT 236 on 6/15/06

 

Review Questions

  1. What do the following symbols mean in VB.NET?
    &     _     .     ( )     { }     "     '
    Ans: They mean concatenation ( & ), line continuation ( _ ), member selection operator ( . ), method call ( ( ) ), nothing in VB ( { } ), string delimiters ( " ), start of comment ( ' ).

  2. List four ways to start a VB.NET application.
    Ans: Start button (triangular), Main Menu Debug >> Start, F5, double click on .exe file using the Windows Explorer.

  3. List as many ways as you can to to stop a VB.NET application.
    Ans: Stop button (square), Alt F4, Close Button in the application control panel, click on image icon on left of title bar >> Close, right click on application in Taskbar >> Close, Use Control-Alt-Delete to invoke Task Manager and close application with it, use Me.Close( ) in the code.

  4. What do Option Explicit On and Option Strict On mean?
    Ans: It means that automatic type conversions will NOT be performed.

  5. What is the difference between a console application and a Windows application?
    Ans: A console application is prescriptive in the sense that its code tells the application what to input, what computations to perform, and what to output. A Windows application is reactive in the sense that it waits for the user to generate events (like Click or TextChanged) and then executes event handlers in response to those events.

  6. What two properties should you immediately set after you place a new control on a form?
    Ans: Change the name to something more meaningful and set the Text property to make the application clear on the application user interface.

  7. What is the difference between a method and an event?
    Ans: A method is something that the object does. An event is something that happens to the object that the object can detect.

  8. What is an event handler?
    Ans: A method that executes when the corresponding event occurs.

  9. How do you create an event handler for a control using the .NET IDE?
    Ans: Double click on the control to get the default event for the control. Use the drop down boxes above the Code Window to pick the control and event for an event handler more precisely.

  10. What is the default event for a control?
    Ans: Every control has an event designated as its default event. When the user double clicks on that control in the Form Designer Window, an event handler for the default event is created.

  11. Write a line of code that will display the image "c:\roses.gif" in the picture box picFlower. Ans:
    picFlower.Image = Image.FromFile("c:\roses.gif")

  12. Give two ways of changing the Text property of the textbox txtA to "abc".
    Ans: Set the Text property of txtA in the Properties Window, Use the code txtA.Text = "abc".

  13. Explain the difference between
    System.Console.WriteLine("Hello")
    and
    System.Console.Write("Hello")
    Ans: After writing its output to the console, WriteLine goes to a new line, whereas Write holds the line for the next output.

  14. Use
    System.Console.WriteLine
    to output the greeting Hello, contatenated with the current value of the string variable name. Ans:
    System.Console.WriteLine("Hello, " & name & ".")
 

Intellisense

 

Namespaces

 

The Imports Statement

 

Practice Problems

 

Constants, Variables, and Datatypes

 

Operators

 

Practice Problem

Answer. Here is the variable trace table:

x y
5 7
17 10
47 13

Here is the output:
47 13
 

Some Examples

 

Changing the Name of a Form

To change the name of the form from Form1 to (say) frmMain:

  1. Change the name of the Form in the properties window from Form1 to frmMain. This will have the effect of changing the name of the class in the code also.

  2. Change the name of the source code file in the Solution Explorer from Form1.vb to frmMain.vb.

  3. Right click on the name of the Project in the Solution Explorer, then choose Properties.
    Change the name of the Startup object from Form1 to frmMain.

 

Some Controls

 

The Control Class

 

Some Properties of the Form Class

 

The Form_Load Event Handler

 

Practice Problems

  1. Work Problem 38 on Page 71 in the textbook.
 

The CurrencyConverter Project

 

Running a Windows Example using Visual Studio 2005