Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Let property of VBA class modules - is it possible to have multiple arguments? [duplicate]

Tags:

People also ask

What is the difference between let and set in VBA?

Let statements can be used to assign one record variable to another only when both variables are of the same user-defined type. Use the LSet statement to assign record variables of different user-defined types. Use the Set statement to assign object references to variables.

What's the difference between a module and a class module in VBA?

A class is more of a unit, and a module is essentially a loose collection of stuff like functions, variables, or even classes. In a public module, classes in the project have access to the functions and variables of the module. You don't have to specify the module name to address one.

How do I create a class module in VBA?

Class module in VBA can be defined as the module that helps to create your own objects with your own properties and methods like worksheets and range objectives of excel. In simple terms with the help VBA class module, we can create objects with own properties.

What are modules for in VBA?

VBA module is a “. bcf” extension file that holds the code in the visual basic editor. Each module has its own code window where you can write. You can insert a new module, delete, backup, and import it.


My understanding of using the Let property in a class module so far is that you set it up in the class modules like this:

Dim pName as String
Public Property Let Name(Value As String)
    pName = Value
End Property

And then you after you've created an object of this class you can set this property like so:

MyObject.Name = "Larry"



Question: Is it possible to somehow enter multiple arguments into a class property? For instance:

Dim pFirstName as String, pLastName as String
Public Property Let Name(FirstName As String, LastName As String)
    pFirstName = FirstName
    pLastName = LastName
End Property

How would you then go about setting this property outside the class?

MyObject.Name = ??

Or is this just plain not possible to do?