jojoSATX wrote:
Function convertDictionaryFromRowTag(myRowTag as Variant) As myListboxDictionary
dim dict as new myListboxDictionary
if myRowTag isa myListboxDictionary then
dict = myListboxDictionary(myRowTag)
end if
Return dict
End Function
I would recommend not creating a new dictionary/class instance in this method. If the rowtag is not of the expected type, you are creating a new instance and your calling method will not know that the returned value is not the actual rowtag for the row. You shouldn't have any problems if you are only reading the values, but if your calling method alters the contents (or the code is changed at a later date to alter the contents) any changes will not be updated in the actual rowTag. And that could be hard to locate the cause by that time.
IMHO, it's best to return null so that the calling method will know that the rowtag is not the expected type, and handle the situation properly.
I personally prefer Tim's suggestion to use CellTags. You can access the celltag of a cell that is not displayed (if your listbox has 5 columns, you can still access celltags from 6 to the maximum), giving you a large number of available cells to store data.