VB课程LessonC.ppt

Steps to Design a Visual Basic Application Plan the Application Build the User Interface : Code the Application Testing and Debugging Assemble the documentation Step 3 - Code the Application Determine the events that the controls on the window should recognize. Write the event procedures for those events. (1) Code the Print order button Print Order Button Hide the 4 command buttons Print the form Display the 4 command buttons Send the focus to the clear screen button Hide the 4 command buttons Set visible property to False cmdCalc.Visible=False cmdPrint.Visible = False cmdClear.Visible = False cmdExit.Visible = False Assignment Statement Use to assign a value to a property. [form.]object.property = value Print the form PrintForm method - prints the form during run time Syntax: [form.]PrintForm Form is optional frmOrder.PrintForm PrintForm Method A method is a predefined Visual Basic procedure. Display the 4 command buttons Set visible property to True. cmdCalc.Visible=True cmdPrint.Visible = True cmdClear.Visible = True cmdExit.Visible = True Send the focus to the clear screen button SetFocus method - allows you to move the focus to a specified control or form while the application is running Syntax: [form.]object.SetFocus cmdClear.Setfocus Documenting the code Documenting the code is a good practice. Place an apostrophe(‘) before the statement. Private Sub cmdPrint_Click() hide command buttons before printing the form cmdCalc.Visible = False … PrintForm display command buttons after the form is printed cmdCalc.Visible = True … cmdClear.SetFocus End Sub (2) Code the Clear Screen Button 文本框 txtName.Text=“” 标签 lblTboards.Caption=“” (3) Code the Calculate Order button Calculate the total skateboards=blue skateboards + yellow skateboards Calculate the total price= total skateboards * skateboard price * (1 + sales tax) Display total skateboards and total price in lblTboards and lblTprice label control. Send focus to the Print O

文档评论(0)

1亿VIP精品文档

相关文档