Interaction.CallByName(Object, String, CallType, Object[]) Yöntem

Tanım

Nesne üzerinde bir yöntem yürütür veya nesne üzerinde bir özellik ayarlar veya döndürür.

public:
 static System::Object ^ CallByName(System::Object ^ ObjectRef, System::String ^ ProcName, Microsoft::VisualBasic::CallType UseCallType, ... cli::array <System::Object ^> ^ Args);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of ObjectRef cannot be statically analyzed and its members may be trimmed.")]
public static object? CallByName(object? ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object?[] Args);
public static object? CallByName(object? ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object?[] Args);
public static object CallByName(object ObjectRef, string ProcName, Microsoft.VisualBasic.CallType UseCallType, params object[] Args);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of ObjectRef cannot be statically analyzed and its members may be trimmed.")>]
static member CallByName : obj * string * Microsoft.VisualBasic.CallType * obj[] -> obj
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

Parametreler

ObjectRef
Object

Gerekli. Object. Özelliğini veya yöntemini kullanıma salayan nesne işaretçisi.

ProcName
String

Gerekli. String. Nesnedeki özelliğin veya yöntemin adını içeren dize ifadesi.

UseCallType
CallType

Gerekli. Çağrılan yordamın CallType türünü temsil eden türde bir numaralandırma üyesi. değeri CallType , Methodveya GetolabilirSet.

Args
Object[]

Optional. ParamArray. Çağrılan özelliğe veya yönteme geçirilecek bağımsız değişkenleri içeren bir parametre dizisi.

Döndürülenler

Nesne üzerinde bir yöntem yürütür veya nesne üzerinde bir özellik ayarlar veya döndürür.

Öznitelikler

Özel durumlar

Geçersiz UseCallType değer; , Methodveya GetolmalıdırSet.

Örnekler

Aşağıdaki örnekte, ilk satır bir metin kutusunun özelliğini ayarlamak için kullanırCallByName, ikinci satır özelliğin Text değerini alır ve üçüncü satır metin kutusunu taşımak için yöntemini çağırırText.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

Sonraki örnek, bir koleksiyon nesnesinin CallByNameAdd ve Item yöntemlerini çağırmak için işlevini kullanır.

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

Açıklamalar

CallByName İşlev çalışma zamanında bir özellik almak, özellik ayarlamak veya bir yöntem çağırmak için kullanılır.

Şunlara uygulanır

Ayrıca bkz.