Name

CallByName Function

Class

Microsoft.VisualBasic.Interaction

Named Arguments

Yes, if Args ( ) is omitted

Syntax

CallByName(Object, ProcName, UseCallType, Args(  ))
Object

Use: Required

Data Type: Object

A reference to the object containing the procedure being called.

ProcName

Use: Required

Data Type: String

The name of the procedure to call.

UseCallType

Use: Required

Data Type: CallType Constant

A constant of the type CallType indicating what type of procedure is being called. CallType constants are listed in the following table.

Constant

Value

Description

Method

1

The called procedure is a method.

Get

2

The called procedure retrieves a property value.

Let

4

The called procedure sets the value of a property.

Args

Use: Optional

Data Type: Any

A ParamArray argument representing the arguments required by the procedure being called.

Return Value

Depends on the return value (if any) of the called procedure

Description

Provides a method for calling a class member by name.

Since ProcName is a string expression, rather than the literal name of a routine, it is possible to call routines dynamically at runtime using a string variable to hold the various procedure names.

Rules at a Glance

  • The return type of CallByName is the return type of the called procedure.

  • ProcName is not case sensitive.

  • UseCallType can either be a numeric value or a constant of the CallType enumeration. In the latter case, the enumeration name must be specified along with the constant name, as in CallType.Method. ...

Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.