- Code: Select all Expand viewCollapse view
Sub inSort(anElement as variant, aList as object)
Dim anIndex as Long
anIndex = sortIndex(anElement)
Function sortIndex(anElement as variant) as Long
If isObject(anElement) then
sortIndex = anElement.sortIndex
elseif isNumeric(anElement) then
sortIndex = anElement
sortIndex = len(anElement)
This works just fine when I give it an object variable (with a sortIndex property, of course), but I get an 'Object variable not set' error when I give it any other type. The error occurs on the call to sortIndex(...), not on the call to inSort(...), so I know that Basic is concerned about my use of the dot operator, disregarding my use of the Variant (or even the Any type) as well as my use of the isObject function as a condition.
The error also occurs any time the Null type or the Nothing object is passed to a procedure. This is less a pain to work around.
That accounts for about 96% of the errors I encounter during debugging, so if anyone could tell me how to coax Basic into letting me use the same parameter for both object and primitive types, it would be abundantly appreciated.