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[]

Optional. ParamArray; 호출되는 속성 또는 메서드에 전달할 인수를 포함하는 매개 변수 배열입니다.

반품

개체에서 메서드를 실행하거나 개체의 속성을 설정하거나 반환합니다.

예외

값이 잘못 UseCallType 되었습니다MethodGetSet.

예제

다음 예제에서 첫 번째 줄은 텍스트 상자의 속성을 설정하는 Text 데 사용하고CallByName, 두 번째 줄은 속성 값을 Text 검색하고, 세 번째 줄은 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 함수는 런타임에 속성을 얻거나, 속성을 설정하거나, 메서드를 호출하는 데 사용됩니다.

적용 대상

추가 정보