In this case the method signature will accept as the parameter the Key we want to retrieve (the class member put after the dot), returning always a String, in order to simplify this example. Now, how can we retrieve values for these not existing members using the dot notation? As you probably guessed, we need to add an additional method that overloads Operator_Lookup. In addition, you can see how we can assign several types of values to these: an Integer, a String and a Color value. Dim pr As New MyPreferencesĪs you can see, Page, Index and BaseColor are not members of our class these are captured as Keys for the Dictionary thanks to the Operator_Lookup operator. These members are captured by the Operator_Lookup method, adding the member as the key for a new entry in the dictionary (this is the text we write after the dot) and assigning to it the value we put after the equal symbol (the assignation operator) thanks to the use of the assigns keyword in the parameters declaration for the Operator_Lookup method. If we add the Open Event to the project and write the below snippet of code, we will see how we can use the dot notation to use and access class members that have never been added to the class. Once implemented, we can take advantage of the feature. Writing the following line of code in the resulting Code Editor: data.Value( key ) = value
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |