Building an Application in the Visual Basic .NET Environment - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Building an Application in the Visual Basic .NET Environment

Description:

Chapter 3 Building an Application in the Visual Basic .NET Environment Objectives Design a Visual Basic .NET application Start a new Visual Basic .NET project Change ... – PowerPoint PPT presentation

Number of Views:413
Avg rating:3.0/5.0
Slides: 45
Provided by: steve1727
Category:

less

Transcript and Presenter's Notes

Title: Building an Application in the Visual Basic .NET Environment


1
Chapter 3
  • Building an Application in the Visual Basic .NET
    Environment

2
Objectives
  • Design a Visual Basic .NET application
  • Start a new Visual Basic .NET project
  • Change the size of a form
  • Change the property values of a form
  • Add controls to a form

3
Objectives
  • Move and resize controls on a form
  • Use the Label, TextBox, NumericUpDown, and Button
    controls
  • Change the property values of controls
  • Change the Name property to rename a control
  • Write the code for a Click event procedure

4
Objectives
  • Display line numbers in the code window
  • Use control properties in a method
  • Document code with a comment header and comment
    statements

5
(No Transcript)
6
Program Development
7
Starting a New Project
  • Start Visual Basic .NET. When the Start Page
    displays, click the New Project button on the
    Start Page
  • Click the More button
  • Click the Create directory for Solution check
    box. Double-click the text, WindowsApplication1,
    in the Name box. Type State Tax Computation in
    the Name box

8
Starting a New Project
  • Click the Browse button. If necessary, select 3½
    Floppy (A) in the Look in box. Double-click
    Chapter3 in the Look in list
  • Click the Open button
  • Click the OK button and, if necessary, click the
    Maximize button on the Visual Basic .NET title
    bar to maximize the window

9
(No Transcript)
10
Changing the Size of a Form
  • Click the Form1 form in the main work area.
    Point to the center sizing handle on the forms
    right border
  • Drag the forms right border to the left to
    decrease the form width by approximately one-half
    inch
  • Point to the center sizing handle on the forms
    bottom border and then drag the forms bottom
    border up to decrease the form height
    approximately one-half inch

11
(No Transcript)
12
Using the Property Window
  • Object Box
  • Property List
  • Toolbar
  • Categorized button
  • Alphabetic button
  • Properties button
  • Property Pages button
  • Description Pane

13
Changing StartPosition, Title, and
FormBorderStyle Property Values
14
Changing StartPosition, Title, and
FormBorderStyle Property Values
  • Click the title bar of the Form1 form to select
    the form. Scroll the Properties list until the
    FormBorderStyle property displays
  • Click the Sizable value next to the
    FormBorderStyle property. Click the
    FormBorderStyle box arrow next to the value,
    Sizable

15
Changing StartPosition, Title, and
FormBorderStyle Property Values
  • Click Fixed Dialog in the FormBorderStyle
    property values list
  • Scroll down to the Text property, and
    double-click the Form1 value next to the Text
    property
  • Type State Tax Computation as the Text property
    and press the ENTER key

16
Changing StartPosition, Title, and
FormBorderStyle Property Values
  • Scroll the properties list to the StartPosition
    property and click the WindowsDefaultLocation
    value next to the StartPosition property
  • Click the StartPosition box arrow and select
    CenterScreen in the values list

17
Changing Additional Form Property Values
18
Adding Label Controls to a Form
  • Click the Windows Forms tab in the Toolbox
    window, and point to the Label button
  • Click the Label button and point to the
    upper-left corner of the form
  • Drag the mouse pointer down and to the right to
    size the Label control
  • Release the mouse button
  • Click any blank area on the Form1 form

19
Adding TextBox Controls to a Form
  • Point to the TextBox button in the Toolbox window
  • Drag the TextBox button to the right without
    releasing the mouse button
  • Release the mouse button
  • Add a second TextBox control to the form, along
    with 2 more labels

20
Adding a NumericUpDown Control to a Form
  • Click the down scroll arrow in the Toolbox window
    until the NumericUpDown button displays on the
    Windows Forms sheet
  • Drag the NumericUpDown button to the right of the
    Form1 form
  • Click any blank area on the Form1 form

21
Adding Button Controls to a Form
  • Double-click the Button button in the Toolbox
    window
  • Add a second Button control to the form
  • Click and drag the controls to position them as
    shown on the following slide

22
(No Transcript)
23
(No Transcript)
24
Changing Properties of Controls
  • Single-click the control for which you wish to
    change the properties
  • In the Property window, scroll down to the
    property you wish to change and type or select
    the property value next to the property name
  • Set the properties of your controls according to
    the tables on the following slides

25
(No Transcript)
26
(No Transcript)
27
(No Transcript)
28
(No Transcript)
29
Changing the Name Property of Controls
  • Name property
  • Naming conventions

30
TextBox and NumericUpDown Control Methods
  • Event-driven program
  • Events are messages sent to an object
  • Click event
  • Event procedures, triggered by events, are groups
    of code statements
  • Code statements are instructions to the computer
    written at design time for the computer to
    execute at run time

31
Assignment Statements
  • controlname.propertynamepropertyvalue

32
Comment Statements
33
Writing Code in the Code Window
  • Intellisense anticipates your needs during coding
    and displays prompts to assist you in coding
  • A syntax error is an error caused by code
    statements that violate one of the structure or
    syntax rules of the Visual Basic .NET language

34
Showing Line Numbers and Writing Code for a
Comment Header and the btnCompute_Click Event
Procedure
  • Select Options from the Tools menu on the menu
    bar and click the Text Editor folder in the
    Options dialog box
  • Click the Basic folder below the Text Editor
    folder and click Line numbers in the Display area
  • Click the OK button

35
Showing Line Numbers and Writing Code for a
Comment Header and the btnCompute_Click Event
Procedure
  • Double-click the Compute Tax button on the Form1
    form in the main work area
  • Type the five comment header lines (excluding
    line numbers) as shown below

36
Showing Line Numbers and Writing Code for a
Comment Header and the btnCompute_Click Event
Procedure
  • On the blank line below the word, Private, type
    lines 142 and 143 of code, as shown below
  • Click the Form1.vbDesign tab

37
Writing Code for the btnReset_Click Event
Procedure
  • Double-click the Reset button on the Form1 form
    in the main work area
  • Enter the code below
  • Click the Form1.vbDesign tab

38
Saving and Testing the Application
  • Click the Save All button on the Standard toolbar
  • Click the Start button on the Visual Basic .NET
    Standard toolbar
  • Click the Minimize button on the Visual Basic
    .NET title bar. Type 50000 in the Taxpayers
    income text box and then select the number 3 for
    the number of dependents
  • Click the Computer Tax button

39
Click the Close button on the applicationand
Maximize the Visual Basic .NET window
40
Documenting the Application and Quitting Visual
Basic .NET
  • Close the Output window. Click the
    Form1.vbDesign tab and use the PRINT SCREEN
    key, along with your knowledge from Chapter 2, to
    record the user interface design
  • Click the Form1.vb tab. Click File on the menu
    bar and then click Page Setup

41
Documenting the Application and Quitting Visual
Basic .NET
  • Use the Print command on the File menu to print a
    record of the code of the State Tax Computation
    form
  • Click the Visual Basic .NET Close button

42
Summary
  • Design a Visual Basic .NET application
  • Start a new Visual Basic .NET project
  • Change the size of a form
  • Change the property values of a form
  • Add controls to a form

43
Summary
  • Move and resize controls on a form
  • Use the Label, TextBox, NumericUpDown, and Button
    controls
  • Change the property values of controls
  • Change the Name property to rename a control
  • Write the code for a Click event procedure

44
Summary
  • Display line numbers in the code window
  • Use control properties in a method
  • Document code with a comment header and comment
    statements
Write a Comment
User Comments (0)
About PowerShow.com