cs130 project 1 a simple vb application ("project" or program): user enters amount of...

104
CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays the correct the "commission"

Upload: howard-stephens

Post on 13-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

CS130 Project 1

A simple VB application ("project" or program): user enters amount of sales then

clicks the "Calculate button", the application displays the correct the "commission"

Page 2: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Structure of the "Desktop" and a "Window"

Page 3: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Commission" application

Page 4: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

How to launch MS VB6.0 IDE from Desktop: start from the "task bar"

Page 5: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "New Project" window: note the various types of projects

Page 6: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Configuring the VB environment: single document Interface (SDI)

Page 7: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Configuring the VB environment: single document Interface (SDI) continued

Select the "SDI Development Environment"

Page 8: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Configuring the VB environment: single document Interface (SDI) continued

Deselect the "Default to Full Module View"

Page 9: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 10: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Close and restart VB, choose "Standard EXE" as before VB displays "Tool Box", "Form", "Project", and

"Properties" windows

Page 11: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Using "Tool Box" and "Properties" windows, you can easily design the layout (buttons and boxes, etc.) of the

desired GUI of your application in the "Form" window.Note that the "Pointer" tool (an arrow) is now being selected

Page 12: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Right click anywhere in the gray area of the menu bar displays the "Shortcut" menu

Page 13: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 14: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Only one window can be active at a time; "Form" window is now the active window

Page 15: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Resizing the a window: move the Pointer to the border of a window, the arrow pointer

changes to a double-headed arrow

Page 16: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Resizing the a window: notice the double-headed arrow continued

Page 17: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Resizing the a window: notice the double-headed arrow continued

Page 18: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Moving a window: move the pointer to the blue Title Bar, drag the window to desired place on the

window as shown in the next slide

Page 19: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 20: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Form" window is now approximately in the middle of the Desktop

Page 21: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The finished GUI for the "Sales Commission" project

Page 22: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Identify the tools available in the Tool Box

• The tool-tips

• Point to a particular tool icon in the Tool Box, VB automatically displays the tool-tip of the icon.

Page 23: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Windows that are needed to design the GUI

Page 24: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Label" icon in the Tool Box is being pointed to

Page 25: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Label" icon in the Tool Box has been selected. Notice the pointer change to a cross

Page 26: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Use the "Label" pointer (a cross) to draw or create a "Label" box (next slide). Each box in the Form window is formally known as an "object" whose "Properties" (attributes) can be defined through the "Properties "

window. Each object or box is also known as a "control"

Page 27: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

A Label Box has been created. Note that the box can be moved (point to the box, hold down the left mouse button and

drag to desired location) and resized (use the resizing handles) as desired

Page 28: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The second Label box is created in similar manner

Page 29: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 30: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Textbox" tool selected

Page 31: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Holding down the left mouse button displays the left and top positions (relative to upper left corner of the Form window 0x0),

size information is displayed in the Properties window

Page 32: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

First Textbox created

Page 33: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Second Textbox created

Page 34: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 35: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

"CommandButton" created

Page 36: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

CommandButton is about to be moved

Page 37: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

CommandButton is moved to new location

Page 38: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 39: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TextBox 1 is being resized (only the height here)

Page 40: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TextBox 1 is being resized (only the height here) continued

Page 41: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TextBox 1 has been resized (only the height)

Page 42: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TextBox 2 is being resized

Page 43: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TextBox 2 has been resized

Page 44: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Setting properties of various controls (objects or boxed)

• Each control or object is associated with a set of properties listed in the Properties window.

• The properties are listed alphabetically or by category (you can use either one by clicking the tab of your choice)

Page 45: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Caption" property

• Caption is the text displayed in a control or in the Title bar of a Form.

• Once set, the caption remains unchanged when the application (the program) runs.

Page 46: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Setting the "Caption" property of LabelBox 1. Note the FontColor properties is currently being selected

Page 47: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Caption property is selected. The default is "Label1" and is to be changed to "SALES"

Page 48: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Replace Label1 with SALES in the Properties box

Page 49: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

"Label2" and "Command1" have been changed to "COMMISSION" and "CALCULATE", respectively. Also, "Form1" in the title bar is about to

be changed to "Calculating Sales Commission"

Page 50: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

"Form1" in the title bar has been changed to "Calculating Sales Commission"

Page 51: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Another way of activating an arbitrary control on a Form so that its properties can be

changed

Page 52: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Text" property

• TextBox is usually used to display a value (may be numeric or non-numeric), which may be changed when the application is executed (run).

• In our example, the default values are "Text1" and "Text2" in two text boxes, and both are non-numeric (not numbers). We want to change the default values to "blanks" in our example. In other word, before the application is run, we want to display nothing (blanks) in these two boxes.

Page 53: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Change "Text1" and "Text2" to blanks in textbox1 and textbox 2

Page 54: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Change "Text1" and "Text2" to blanks in textbox1 and textbox 2 continued

Page 55: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Change "Text1" and "Text2" to blanks in textbox1 and textbox 2 continued

Page 56: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Change "Text1" and "Text2" to blanks in textbox1 and textbox 2 continued

Page 57: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Both text boxes have been blanked

Page 58: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "Locked", "TabIndex" and "TabStop" properties

• The Locked property prevents the content of a text box from being changed (if set from "false" to "ture").

• The TabIndex property controls the order or moving from box to box as the Tab key is pressed (0, 1, 2, 3, etc.).

• The "TabStop" property determines if a box is to be skipped if the Tab key is pressed (false to skip)

Page 59: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Setting the TabStop property of a text box; also the Locked property has been set to true

Page 60: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

TabStop has been set to false for the CALCULATE control

Page 61: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Form1has been selected (click any empty area on the form)

Page 62: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Change the "Name" property of a control or object (it is critical to know that the name and caption are

two different properties!!!)

Page 63: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

The "name" property of Form1 (default) has been changed to SLSCOMSN

Page 64: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Form1 is not changed to SLSCOMSN in the Project window

Page 65: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays

Writing code (instruction): the more interesting and challenging part of application design

• The boxes you've so far created are just a GUI; nothing useful will happen to them unless appropriate code (program modules) is associated with those boxes.

• The code (coded in BASIC language) allows actions to be triggered, e.g., if SALSE amount has been properly entered, upon clicking the CALCULATE button (control), computed commission will be displayed.

Page 66: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 67: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 68: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 69: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 70: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 71: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 72: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 73: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 74: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 75: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 76: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 77: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 78: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 79: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 80: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 81: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 82: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 83: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 84: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 85: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 86: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 87: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 88: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 89: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 90: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 91: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 92: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 93: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 94: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 95: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 96: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 97: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 98: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 99: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 100: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 101: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 102: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 103: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays
Page 104: CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays