How to: Get a Value from a Property (Visual Basic)
You retrieve a property's value by including the property name in an expression.
Get procedure retrieves the value, but you do not explicitly call it by name. You use the property just as you would use a variable. Visual Basic makes the calls to the property's procedures.
To retrieve a value from a property
Use the property name in an expression the same way you would use a variable name. You can use a property anywhere you can use a variable or a constant.
Use the property name following the equal (
=) sign in an assignment statement.
The following example reads the value of the Visual Basic
Nowproperty, implicitly calling its
Dim ThisMoment As Date ' The following statement calls the Get procedure of the Visual Basic Now property. ThisMoment = Now
If the property takes arguments, follow the property name with parentheses to enclose the argument list. If there are no arguments, you can optionally omit the parentheses.
Place the arguments in the argument list within the parentheses, separated by commas. Be sure you supply the arguments in the same order that the property defines the corresponding parameters.
The value of the property participates in the expression just as a variable or constant would, or it is stored in the variable or property on the left side of the assignment statement.
- Property Procedures
- Procedure Parameters and Arguments
- Property Statement
- Differences Between Properties and Variables in Visual Basic
- How to: Create a Property
- How to: Declare a Property with Mixed Access Levels
- How to: Call a Property Procedure
- How to: Declare and Call a Default Property in Visual Basic
- How to: Put a Value in a Property
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.