You have seen Functions and Procedures in Visual Basic; Visual Basic also includes Methods . Methods operate in the same manner as procedures and functions , but they are components of specific objects, just as properties and field names are. To call a method , the syntax is as followed :
Objectname.Method
Hence to call the print method you could write Debug.Print .
Visual Basic has no print procedure. Instead, all the objects to which you can write have a method named Print . If you want to print a string say "Visual Basic" to a Form named TryForm , you would write the following code :
TryForm.Print "Visual Basic"
The printer , in Visual Basic is represented by a special object named Printer, Hence if you want to write to the printer, you will have to type :
Printer.Print "Visual Basic"
Often Visual Basic allows you to omit the object name when using a method . If you do this, Visual Basic directs the method to the object it believes you intended - usually the current Form. To avoid ambiguity, you can always use the full Object.Method naming Convention. Methods can act like procedures and functions . They can simply perform a service as the Print method does , or they can return values.
No comments:
Post a Comment