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

1 / 20
About This Presentation
Title:

Building an Application in the Visual Basic 'NET Environment

Description:

Consider visual aesthetics ONLY AFTER functional considerations have been determined ... Use proper spacing and indention to make code more readable ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 21
Provided by: Staf964
Category:

less

Transcript and Presenter's Notes

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


1
Building an Application in the Visual Basic .NET
Environment
  • Shelly, Cashman, Quasney
  • Chapter 3

2
Analyze problem
  • Analyze the state tax computation problem

3
Interface Design
A user interface is the way a program
accepts data and presents results
  • GUI provides visual cues
  • Consider inputs, processes, outputs to choose
    appropriate controls
  • Consider visual aesthetics ONLY AFTER functional
    considerations have been determined

4
Input areas
  • Use TextBox controls to allow the user to enter
    any amount
  • To limit the users input entry consider using a
    ListBox control

5
Output area
  • A TextBox may be used to display output
  • Visual clues tell the user not to use this area
    for input
  • Change the background to gray
  • Restrict ability to input data

6
Processing
  • Button controls allow a user to indicate an action

Compute Tax
Reset
7
Program Design
  • What are the 2 program tasks?
  • Create processing algorithms for each

8
Working with Form Properties
A form is an instance of the System.Windows.Forms.
Form class
  • Adjust the form size to accommodate the input and
    output areas as well as other user interface
    elements
  • When a form is resized by dragging its borders,
    the Width and Height properties are automatically
    updated
  • Width and height measures are in pixels
  • Consider a typical PC monitor to contain 96
    pixels per inch

9
Object box
Toolbar
Expand and collapse property buttons
Initial default values are set for every property
of a control
Property values
Properties list
10
Modifying Form Properties
  • StartPosition property specifies where the
    application displays on the desktop
  • Default WindowsDefault
  • Text property controls the display in the title
    bar
  • Default Form1
  • FormBorderStyle property controls the appearance
    of the border
  • Default Sizable

More commonly used properties p. 3.22
11
Windows App Controls
Use the Toolbox window to add controls
to a form
12
Adding Controls to a Form
  • Draw
  • Drag
  • Double-click

13
Moving Controls on a Form
  • Drag the control to a new location
  • Set properties of the control
  • Top property determines number of pixels that the
    top left corner of the control displays from the
    top of the form
  • Left property determines number of pixels that
    the top left corner of the control displays from
    the left side of the form

Use the DELETE key to delete a selected
control
14
Setting Control Properties
Common control properties p. 3.39
  • When a user selects a control, a control is said
    to have focus
  • A control can receive the focus by tabbing (using
    the TAB key)
  • The TabIndex property determines the order of
    focus on controls when a user presses the TAB key
  • To skip a control during tabbing, set the TabStop
    property to False

15
The Name Property
  • Visual Basic .NET assigns unique default names
  • Use the Name property to provide a more
    descriptive name
  • Rename controls that will be referred to in code
  • Follow a standardized naming convention so that
    the control is easily identified in code

16
Simple Naming Convention Standards
  • The Name property of the control should
  • Indicate the type of control
  • Use a three-letter prefix
  • Describe the purpose of the control
  • BE CERTAIN to name controls BEFORE writing any
    code

txt TextBox controls lbl Label
controls nud NumericUpDown controls btn
Button controls
17
Writing Code
  • Events are messages sent to an object (control)
    when the application runs
  • Events trigger event procedures groups of code
    statements
  • Code statements are instructions for the computer
    to execute
  • Most controls recognize the Click event
  • Programs that respond in this way are called
    event driven

18
Assignment Statements
  • Assignment statements change the value of a
    variable or property of a control
  • Syntax
  • controlname.propertyname propertyvalue
  • Assign the propertyvalue on the right side of the
    statement to the propertyname of the controlname
    on the left side of the statement

Assignment statements work from right to left
19
Comment Statements
  • A comment is text added within an event procedure
    to explain processing
  • Comments are ignored by the .NET CLR
  • Comment lines begin with an apostrophe (') OR the
    letters REM
  • Use a comment header the file and
  • its purpose at the top of every class file
  • 2. Place a comment at the top of every function
  • or procedure
  • 3. Place comments near code that needs
  • clarification

20
The Code Window
  • Visual Basic .NET automatically numbers all lines
    of code
  • Intellisense anticipates your needs during coding
    and displays prompts for assistance
  • Use proper spacing and indention to make code
    more readable
Write a Comment
User Comments (0)
About PowerShow.com