Presentation is loading. Please wait.

Presentation is loading. Please wait.

Managing Controls Lab 2 2 All Rgihs ReservedIsmail M. Romi – PPu: IT DEpt.

Similar presentations


Presentation on theme: "Managing Controls Lab 2 2 All Rgihs ReservedIsmail M. Romi – PPu: IT DEpt."— Presentation transcript:

1 Managing Controls Lab 2 2 All Rgihs ReservedIsmail M. Romi – PPu: IT DEpt

2 Properties Set of attributes for each object used in VB, that changes the appearance and behavior of a Form or Control. Properties Types: 1- Design-time properties: properties than can be changed at the design mode. 2- Run-time properties: properties that can be changed at the run-time

3 Properties… Cont. Notes: The Form’s Name property should be unique in the project. The Control’s Name property should be unique on the same form. Name property can be changed at the design mode only.

4 The Form’s Properties Text: The text that appears in form's title bar.. Icon: Displays an icon when the form is minimized. Picture: Image placed as a background to the form. Changing Form Properties at Run-Time: Syntax: Me.PropertyName = Value Examples: Me.Text = "student record" Me.BackColor = Color.Red

5 Form Events Load : Occurs during loading the form into main memory. Unload : Occurs when removing the form from main memory. Note: You can find all form and other Control’s events in the code window in the events ComboBox.

6 The Pointer Tool The pointer tool is not a control. This tool used to deselect any selected control in the toolbox

7 The Label Control A control that displays un editable text to the user. This control used to: 1- Provide a heading or description on the form. 2- Identify another control.

8 Changing Control Properties at Run-Time Syntax: Me.ControlName.Property = Value Example: Me.Label1.Text = "StudentName:“ Me.Label1.forecolor= color.red

9 The Text Box Control A control used for accepting user input, and displaying text at the run-time. Properties: MaxLength: determines the maximum number of characters.(0:open). Multiline: (True/False), enables word wrap. Scrollbars: (0:no, 1:Horizontal, 2:Vertical, 3:Both), enables the user to scroll the text. Scrollbars related with multiline

10 Text Box Properties..[CONT] Locked: True/False Passwordchar: Determines the character that appears when the user enters a text. Text: Specifies the initial text that appears in the text box.

11 Text Box Events TextChanged: Occurs when the vale of the text property is modified. Keypress, Keydown, Keyup…. Focus: The currently selected control. Gotfocus Event: Occurs when the control have the focus. Lostfocus:

12 Button Control A control that represents a button. The user press or clicks to initiate an action. Properties Text: Specifies the text that appears in the button. When you precede a letter with &, that letter becomes the accelerator key. Events: Click, Dbclick……..

13 The Programming Process  The Programming Process Consists of Several Steps, Which Include Design, Creation, Testing, and Debugging Activities  The following is an example of programming process.

14 Clearly define what the program is to do For example, the Wage Calculator program: 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 (result is the user’s gross pay) Output: Display a message indicating the user’s gross pay Step 1 of Developing an Application

15 Visualize the application running on the computer and design its user interface Step 2 of Developing an Application

16 Make a list of the controls needed Step 3 of Developing an Application TypeNameDescription TextBoxtxtHoursWorkedAllows the user to enter the number of hours worked. TextBoxtxtPayRateAllows the user to enter the hourly pay rate LabellblGrossPayDisplays the gross pay, after the btnCalcGrossPay button has been clicked ButtonbtnCalcGrossPayWhen clicked, multiplies the number of hours worked by the hourly pay rate ButtonbtnCloseWhen clicked, terminates the application Label(default)Description for Number of Hours Worked TextBox Label(default)Description for Hourly Pay Rate TextBox Label(default)Description for Gross Pay Earned Label Form(default)A form to hold these controls

17 Define values for each control's relevant properties: Step 4 of Developing an Application Control TypeControl NameText Form(Default)"Wage Calculator" Label(Default)"Number of Hours Worked" Label(Default)"Hourly Pay Rate" Label(Default)"Gross Pay Earned" LabellblGrossPay"$0.00" TextBoxtxtHoursWorked"" TextBoxtxtPayRate"" ButtonbtnCalcGrossPay"Calculate Gross Pay" ButtonbtnClose"Close"

18 List the methods needed for each control: Step 5 of Developing an Application MethodDescription btnCalcGrossPay_ClickMultiplies hours worked by hourly pay rate These values are entered into the txtHoursWorked and txtPayRate TextBoxes Result is stored in lblGrossPay Text property btnClose_ClickTerminates the application

19 Create pseudocode or a flowchart of each method: Pseudocode is an English-like description in programming language terms A flowchart is a diagram that uses boxes and other symbols to represent each step Step 6 of Developing an Application Start End Multiply hours worked by hourly payrate. Store result in sngGrossPay. Copy value in sngGrossPay to lblGrossPay text property

20 Check the code for errors: Read the flowchart and/or pseudocode Step through each operation as though you are the computer Use a piece of paper to jot down the values of variables and properties as they change Verify that the expected results are achieved Step 7 of Developing an Application

21 Use Visual Basic to create the forms and other controls identified in step 3 This is the first use of Visual Basic, all of the previous steps have just been on paper In this step you develop the portion of the application the user will see Step 8 of Developing an Application

22 Use Visual Basic to write the code for the event procedures and other methods created in step 6 This is the second step on the computer In this step you develop the methods behind the click event for each button Unlike the form developed on step 8, this portion of the application is invisible to the user Step 9 of Developing an Application

23 Attempt to run the application - find syntax errors Correct any syntax errors found Syntax errors are the incorrect use of an element of the programming language Repeat this step as many times as needed All syntax errors must be removed before Visual Basic will create a program that actually runs Step 10 of Developing an Application

24 Run the application using test data as input Run the program with a variety of test data Check the results to be sure that they are correct Incorrect results are referred to as a runtime error Correct any runtime errors found Repeat this step as many times as necessary Step 11 of Developing an Application

25 Lab Training Design a VB project to perform the following: Accept two numbers in text boxes. Add two command buttons: Add, End When you click Add, the result of addintion should appear in a label control. When you click End the program end.

26 Questions Design a VB project to: Calculate student average for three grades. Use three buttons : 1 st one for new 2 nd calculate 3 rd close You have to follow the solution steps.

27 Lab 2 End


Download ppt "Managing Controls Lab 2 2 All Rgihs ReservedIsmail M. Romi – PPu: IT DEpt."

Similar presentations


Ads by Google