Share via


Calling Methods

Once an object has been created, you can call the methods of that object from anywhere in your application.

To call a method

  • Use this syntax:

    Parent.Object.Method

The following statements call methods to display a form and set the focus to a text box:

frsFormSet.frmForm1.Show
frsFormSet.frmForm1.txtGetText1.SetFocus

Methods that return values and are used in expressions must end in open and closed parentheses. For example, the following statement sets the caption of a form to the value returned from the user-defined method GetNewCaption:

Form1.Caption = Form1.GetNewCaption( )

Note   Parameters passed to methods must be included in parentheses after the method name; for example, Form1.Show(nStyle). passes nStyle to Form1's Show method code.

See Also

Object-Oriented Programming | Classes and Objects: The Building Blocks of Applications | Classes in Visual FoxPro | Preparation for Class Creation | Creating Classes | Modifying a Class Definition | Subclassing a Class Definition | Operating the Class Designer | Class Member Protection and Hiding | Specifying Design-Time Appearance for a Class | Creating, Copying, and Removing Class Library Files | Adding Classes to Forms | Default Property Setting Override | Container Hierarchy Object Referencing | Setting Properties | Event Response