View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default To declare or not to declare

A variant can hold an object, and that is in essence the third choice. The
only disadvantage would be the size of a variant and Option Explicit
problems if you don't declare it. I assume there would be a slight speed
impact, but for a single variable, I don't see any of the above factors as
really being of great relevance.

Someone else might have a stronger opinion.

--
Regards,
Tom Ogilvy




"Alan Beban" wrote in message
...
Tom Ogilvy wrote:

#Const CaseSensitive = True
#If CaseSensitive Then
Dim x As Dictionary
Set x = New Dictionary
#Else
Dim x As Collection
Set x = New Collection
#End If

But the compiler constant CaseSensitive is not the same as the variable
casesensitive.

Thanks.

The choices seem to be something like the above, Dim x As Object, or
don't declare x. In this specific case, what's really wrong with the
third choice (which certainly streamlines the code, at least from a
visual standpoint)? And what are the advantages of something like the
above rather than Dim x As Object?

Thanks,
Alan Beban