This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Can take arguments. You declare each argument by specifying the argument name and the data type.
Can have an optional argument. An optional argument must be declared at the end of the argument list and must have a default value.
Can be called by using the Call keyword and providing values for all the arguments that are not optional. You can pass arguments to a sub procedure either by value or by reference.
Can be further categorized as:
General procedures
Event-handling procedures
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Is always invoked implicitly by the code that refers to the property, that is, the code uses the name of the property and provides values for all the arguments that are not optional.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Means redefining a base class procedure in a derived class without changing the name of the procedure. Rules:
You can override procedures that are declared with the Overridable keyword in the base class.
You need to explicitly declare a procedure in the base class with the Overridable keyword in order to override it in the derived class.
Overridden procedures need to have the same arguments as the inherited members from the base class.
The redefined implementation of a procedure in the derived class can call the implementation defined in the parent class by specifying MyBase keyword before the procedure name.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
The customer data entry forms at the call centers of Diaz Telecommunications need to include options to check for a valid customer ID and telephone number. The customer ID should start with the letter ‘C’ and have three digits after it. The telephone number should consist of eight digits. The form should also have the facility to display error messages when incorrect data is entered. Additionally, the form should have the provision to clear the last customer details entered.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Task 1: Identify the checks that need to be applied on the form.
Result:
As per the problem statement, the customer data entry form needs to have a provision to check for a valid customer id and telephone number.
You can add the provision for checking the validity of the customer id and the telephone number by including procedures in the customer data entry application.
Since Visual Basic .NET allows the use of procedure overloading, you can create two versions of a procedure in
the customer data entry application to check the validity of the customer id and the telephone number.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Task 3: Identify the mechanism to display error messages. (Contd.)
Result:
To display an error message to users when an invalid customer id or telephone number is entered in the customers data entry form, you can use either the MessageBox class or the built-in MsgBox()function.
Since MessageBox class offers greater control over the interface of the message box, such as displaying appropriate icons, you should use the MessageBox class to display error message when invalid customer id or telephone number is entered.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
The Employee data entry form in the call centers at Diaz Telecommunications requires options to check for valid employee ID and age entries. The employee ID should start with the letter ‘E’ and have three digits after it. The age should be more than 20 years and less than 61 years. The form should also have the facility to display error messages when incorrect data is entered. Additionally, the form should have a provision to clear the last employee details entered. The details of an employee essentially include the employee id, the employee’s first name, the employee’s last name, the address, the age, the date of joining, the department, and the salary.
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
1. There are two labels named Label1 and Label2 and one button named Button1 on the form, Form1. Predict the output of the code, when Button1 is clicked at run time.
2. There are two labels named Label1 and Label2 and one button named Button1 on the form, Form1. You have created a user-defined Sub procedure called MySub to process information when the user clicks Button1. Predict the output of the code, when the program is executed.
3. There is one label named Label1 and one button named Button1 on the form, Form1. What will be the output of the code when Button1 is clicked at run time?
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
Are used to access the default Font dialog box to change the font of the text or used to open a file by using the Open dialog box and display the contents.
Are of the following types:
ColorDialog
FontDialog
FileDialog
PrintDialog
PageSetupDialog
Introducing Procedures and CommonDialog Classes in Visual Basic .NET
1. What will be the output of the code when Button1 is clicked at run time?
2. The code snippet is written in the Code Editor window of Form1. While building the project, there was a build error. What would you do to resolve the error?
Introducing Procedures and CommonDialog Classes in Visual Basic .NET