Interaction.CallByName(Object, String, CallType, Object[]) メソッド

定義

オブジェクトに対してメソッドを実行するか、オブジェクトのプロパティを設定または返します。

public:
 static System::Object ^ CallByName(System::Object ^ ObjectRef, System::String ^ ProcName, Microsoft::VisualBasic::CallType UseCallType, ... cli::array <System::Object ^> ^ Args);
public static object CallByName(object ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object[] Args);
static member CallByName : obj * string * Microsoft.VisualBasic.CallType * obj[] -> obj
Public Function CallByName (ObjectRef As Object, ProcName As String, UseCallType As CallType, ParamArray Args As Object()) As Object

パラメーター

ObjectRef
Object

必須。 Object。 プロパティまたはメソッドを公開するオブジェクトへのポインター。

ProcName
String

必須。 String。 オブジェクトのプロパティまたはメソッドの名前を含む文字列式。

UseCallType
CallType

必須。 呼び出されるプロシージャの型を表す CallType 型の列挙メンバー。 CallTypeの値は、MethodGet、またはSetできます。

Args
Object[]

オプション。 ParamArray。 呼び出されるプロパティまたはメソッドに渡される引数を含むパラメーター配列。

返品

オブジェクトに対してメソッドを実行するか、オブジェクトのプロパティを設定または返します。

例外

UseCallType値が無効です。MethodGet、またはSetする必要があります。

次の例では、最初の行は CallByName を使用してテキスト ボックスの Text プロパティを設定し、2 行目は Text プロパティの値を取得し、3 行目はテキスト ボックスを移動するために Move メソッドを呼び出します。

' Imports statements must be at the top of a module.
Imports Microsoft.VisualBasic.CallType
Sub TestCallByName1()
    'Set a property.
    CallByName(TextBox1, "Text", CallType.Set, "New Text")

    'Retrieve the value of a property.
    MsgBox(CallByName(TextBox1, "Text", CallType.Get))

    'Call a method.
    CallByName(TextBox1, "Hide", CallType.Method)
End Sub

次の例では、 CallByName 関数を使用して、コレクション オブジェクトの Add メソッドと Item メソッドを呼び出します。

Public Sub TestCallByName2()
    Dim col As New Collection()

    'Store the string "Item One" in a collection by 
    'calling the Add method.
    CallByName(col, "Add", CallType.Method, "Item One")

    'Retrieve the first entry from the collection using the 
    'Item property and display it using MsgBox().
    MsgBox(CallByName(col, "Item", CallType.Get, 1))
End Sub

注釈

CallByName関数は、実行時にプロパティの取得、プロパティの設定、メソッドの呼び出しに使用されます。

適用対象

こちらもご覧ください