Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 5 Do It Yourself Designing

  • View
    219

  • Download
    5

Embed Size (px)

Text of Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 5 Do It Yourself Designing

  • Clearly Visual Basic: Programming with Visual Basic 2008Chapter 5 Do It Yourself Designing

    Clearly Visual Basic: Programming with Visual Basic 2008

  • ObjectivesUse a text box to get user inputPerform an action with a button controlCode a controls Click event procedureStop an application using the Me.Close() instructionClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Delegating the WorkFigure 5-1 Shows Addison Smith problems output, input, and algorithmWhen designing interface for a problemExamine each step in the problems algorithm, along with its output and input itemsAssign meaningful names to each of the controls listed in Figure 5-2Camel case Uppercase letters appear as humps in the nameClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • *Clearly Visual Basic: Programming with Visual Basic 2008

    Clearly Visual Basic: Programming with Visual Basic 2008

  • *Clearly Visual Basic: Programming with Visual Basic 2008

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*Mini QuizIt is customary to show the results of a calculation as a ____.Using Hungarian Notation, which of the following is a good name for the city? cityTextBox TextBoxCity txtCity TxtCityThe three-character ID for a button control name is ______.Page 78- Commission Calculator ProgramCreate a new application program called Commission Calculator ProjectChange font property to Sego UI, 9pt and StartPosition to CenterScreenChange the forms Text Property to Commission CalculatorChange the forms Name to: frmMain

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Delegating the Work (continued)Sentence capitalizationCapitalize only first letter in each word and in any words that are customarily capitalizedExample: identifying labels Book title capitalizationCapitalize first letter in each word, except for articles, conjunctions, and prepositionsExample: button captions Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Making the Interface More User-FriendlyAccess keyAllows user to select a menu using the Alt key in combination with a letter or numberNot case sensitiveShould be assigned to each control (in the interface) that can accept user inputAllows user to work with interface even when mouse becomes inoperativeClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*Quick Access Keys- Driven by the ALT KEY

    Clearly Visual Basic: Programming with Visual Basic 2008

  • *Clearly Visual Basic: Programming with Visual Basic 2008

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Making the Interface More User-Friendly (continued)Tab orderDetermined by number stored in each controls TabIndex propertyWhen interface is first createdTabIndex values reflect the order in which each control was added to the formClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Clearly Visual Basic: Programming with Visual Basic 2008*Tab Order- View- Tab Order

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Do What I Tell You To DoCodeVisual Basic instructionsEvent procedureTells an object how to respond to an eventCode Editor windowUsed to enter an event procedures codeClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • The Me.Close() InstructionTells the computer to close the current formMethod A predefined procedure that you can call (or invoke) when neededGood programming practice: test a procedure after you have coded it

    Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Mini Quiz 2If a text boxs Tab Index is set to 7, its indentifying label should be set to: _______If a text boxs access key is the letter t, you can move the focus to the text box by pressing _____The first line in a procedure (when you double click on a button) is the: ______ procedure headerClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Review QuestionsTo give the user control, assign the task to a: Button Label Picture Box Text BoxWhich of the following designates Z as an access key? *Zip Code ^Zip Code &Zip Code #Zip CodeThe computer processes a buttons click when the user: Clicks the button Uses button access code Tabs to the Button All of the TheseWhich of the following appears in the header and associates the procedure with the btnSave controls Click Event: The answer is: Handles.btnSave.ClickWhich of the following tells the computer to stop an application: The answer is Me.Close () Clearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Page 93 #3 Tip Calculator InterfaceNote: We are just doing Interfaces, Tab Orders, and Access Keys, NOT the programming- Except the Exit Button

  • Page 94 #4 Property Tax SolutionClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Property Tax Solution AlgorithmOutput: annual property tax

    Input: Assessed Value Property Tax Rate

    Algorithm:Enter assessed value and property tax rateCalculate annual property tax by dividing accessed value by 100, and then multiplying the quotient by the property tax rateDisplay the annual property tax

  • Page 95 #5 Sales ProjectClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Sales Solution AlgorithmOutput: Total Sales, North Percent, South Percent, East Percent, West PercentInput: North region sales, South sales, East sales, West sales

    Algorithm: Enter North sales, South Sales, East Sales & West SalesCalculate Total Sales by added up all the regions salesCalculate Norths percent by dividing Norths Sales by Total SalesCalculate Souths percent by dividing Souths Sales by Total SalesCalculate Easts percent by dividing Easts Sales by Total SalesCalculate Wests percent by dividing Wests Sales by Total SalesDisplay Total Sales, Norths Percent, Souths percent, Easts Percent and Wests Percent

  • SummaryA problems input, output, and algorithm Used when designing solutions interfaceText boxes provide area for user to enter dataButtons are used to perform action when clickedOutput items typically appear in label controlsObject names in Hungarian notation Begin with an ID that identifies the objects typeClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

  • Summary (continued)To prevent a label from changing its size while application is running:Change its AutoSize property to FalseA labels BorderStyle property Determines whether the label has a borderAn interfaces tab order Determined by number stored in each controls TabIndex PropertyThe Me.Close() instruction Used to end an applicationClearly Visual Basic: Programming with Visual Basic 2008*

    Clearly Visual Basic: Programming with Visual Basic 2008

    **********