270 likes | 383 Views
An Overview of Visual Basic .NET. Methods of Programming. Procedural Languages Constructed as a set of procedures (operational, functional units) Often used in text-based environments Object-Oriented Constructed as a set of objects
E N D
Methods of Programming • Procedural Languages • Constructed as a set of procedures (operational, functional units) • Often used in text-based environments • Object-Oriented • Constructed as a set of objects • Objects have data elements (i.e. properties) and perform actions (i.e. methods)
Object-Oriented/Event-Driven Languages • Simplifies the task of programming GUI applications. • In object-oriented/event-driven languages, the emphasis of a program is on the objects included in the user interface (such as scroll bars and buttons) and the events (such as scrolling and clicking) that occur when those objects are used
OOP Terminology • OOP is an acronym for object-oriented programming • It means that you are using an object-oriented language to create a program that contains one or more objects • OOD is an acronym for object-oriented design • Like top-down design, which is used to plan procedure-oriented programs, OOD is also a design methodology, but it is used to plan object-oriented programs • OOD divides a problem into one or more objects
Object An Object: • Is Anything that can be seen or touched • Has attributes (properties) that describe it • Has behaviors(events) that the object can either perform or have performed on it
Types of ControlsCh1\Program2 on p.10(This application can be found in the student data files)
Starting and Customizing Visual Studio .NET • Visual Studio .NET is Microsoft’s newest integrated development environment (IDE) • Includes programming languages such as Visual Basic .NET, C++ .NET, C# .NET and J# • Can Create: • A Windows-based application has a Windows user interface and runs on a desktop computer • A console application • A Web-based application, on the other hand, has a Web user interface and runs on a server
.NET FrameworkNew Concepts • Common Language Runtime (CLR) • Execution engine • Memory management • Intermediate Language (IL) • VB.NET compiles to IL • Just-in-time compilation
Language Interoperability .NET: Type SystemStandard C# VB.NET
The Programming Process(1.5) The Programming Process Consists of Several Steps, Which Include Design, Creation, Testing, and Debugging Activities
Example of an Object • This is a GUI object • Data includes number-of-hours-worked, hourly-pay-rate, and gross-pay-earned • Action is to calculate and display gross-pay- earned, given number-of-hours-worked and hourly-pay-rate
Step 1 of Developing an Application • Clearly define what the program is to do • For example: • Purpose: To calculate the user’s gross pay • Input: Number of hours worked, hourly pay rate • Process: Multiply number of hours worked by hourly pay rate (The result is the user’s gross pay) • Output: Display a message indicating the user’s gross pay
Step 2 of Developing an Application • Visualize the application running on the computer and design its user interface
Step 3 of Developing an Application • Make a list of the controls needed • Partial list: TypeNameDescription TextBox txtHoursWorked Allows the user to enter the number of hours worked. TextBox txtPayRate Allows the user to enter the hourly pay rate Label lblGrossPay Displays the gross pay, after the btnCalcGrossPay button has been clicked Button btnCalcGrossPay When clicked, multiplies the number of hours worked by the hourly pay rate Button btnClose When clicked, terminates the application
Step 4 of Developing an Application • Define the Values of Each Control's Relevant Properties: Control TypeControl NameText Form (Default) "Wage Calculator" Label (Default) "Number of Hours Worked" Label (Default) "Hourly Pay Rate" Label (Default) "Gross Pay Earned" Label lblGrossPay "$0.00" TextBox txtHoursWorked "" TextBox txtPayRate "" Button btnCalcGrossPay "Calculate Gross Pay" Button btnClose "Close"
Step 5 of Developing an Application • Make a list of methods needed for each control: MethodDescription btnCalcGrossPay_ClickMultiplies the number of hours worked by the hourly pay rate Thesevalues are entered into the txtHoursWorked and txt-PayRate TextBoxes The result is stored in the lblGrossPay Text property btnClose_Click Terminates the application
Step 6 of Developing an Application • Create a pseudocode version of each method: • Pseudocode is a combination of English and a programming language • For this application:Store Number of Hours Worked times Hourly Pay Rate in grossPay.Store the value in grossPay in lblGrossPay.Text.
Step 7 of Developing an Application • Check the code for errors: • Go step by step through the code, running it in your head as though the computer is running it • Keep track of where in the code is being executed • Keep track of the values of all of the variables
Step 8 of Developing an Application • Use Visual Basic .NET to create the forms and other controls identified in step 3 • This is the first use of Visual Basic .NET, all of the previous steps have just been on paper
Step 9 of Developing an Application • Use Visual Basic .NET to write the code for the event procedures and other methods created in step 6 • This is the second step on the computer
Step 10 of Developing an Application • Attempt to run the application - find syntax errors • Correct any syntax errors found and repeat this step as often as necessary • All of the syntax errors must be removed before Visual Basic .NET will create a program that you can actually run on the computer
Step 11 of Developing an Application • Run the application - once all syntax errors are fixed • Run the program with a variety of test data • Check the results to be sure that they are correct • Correct any errors found • Repeat steps 10 and 11 as many times as necessary
Visual Studio .NET Recent Projects Solution Explorer Dynamic Help Toolbox
Starting a New Project Installed .NET Products Type of Project Name of Project Name and Location Of Project
Toolbox (auto-hidden) Visual Basic .NET Project information Windows Form object Properties window
The Visual Basic .NET Environment • Design Window • Solution Explorer Window • Dynamic Help Window • Properties Window • Docked and Floating Windows • Toolbox