Interaction.CallByName(Object, String, CallType, Object[]) Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Esegue un metodo su un oggetto o imposta o restituisce una proprietà su un oggetto .
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
Parametri
- ObjectRef
- Object
Obbligatorio.
Object. Puntatore all'oggetto che espone la proprietà o il metodo.
- ProcName
- String
Obbligatorio.
String. Espressione stringa contenente il nome della proprietà o del metodo nell'oggetto .
- UseCallType
- CallType
Obbligatorio. Membro di enumerazione di tipo CallType che rappresenta il tipo di routine da chiamare. Il valore di CallType può essere Method, Geto Set.
- Args
- Object[]
Optional.
ParamArray. Matrice di parametri contenente gli argomenti da passare alla proprietà o al metodo chiamato.
Valori restituiti
Esegue un metodo su un oggetto o imposta o restituisce una proprietà su un oggetto .
- Attributi
Eccezioni
Valore non valido UseCallType . Deve essere Method, Geto Set.
Esempio
Nell'esempio seguente la prima riga usa CallByName per impostare la Text proprietà di una casella di testo, la seconda riga recupera il valore della Text proprietà e la terza riga richiama il Move metodo per spostare la casella di testo.
' 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
Nell'esempio seguente viene utilizzata la CallByName funzione per richiamare i Add metodi e Item di un oggetto raccolta.
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
Commenti
La CallByName funzione viene usata in fase di esecuzione per ottenere una proprietà, impostare una proprietà o richiamare un metodo.