Ken
Thu Aug 24 17:27:44 CDT 2006
"Mike D Sutton" <EDais@mvps.org> wrote in message
news:OdYfVo8xGHA.3440@TK2MSFTNGP06.phx.gbl...
> Hi Jeff,
>
>> You don't. TypeOf is an odd beast. Perhaps TypeName() will serve you
>> better.
>
> I'm curious as to how it's an "odd beast", I don't recall ever having any
> problems with it is there some issue I'm unaware with it or just because
> it requires an "Is" which doesn't lend itself well to Select Case
> statements? Personally I would recommend TypeOf over TypeName() both for
> performance and maintenance reasons, it avoids string operations and I
> would assume is pretty much just a direct COM QueryInterface() call so it
> should be nice and fast too.
> Cheers,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@mvps.org
> WWW: Http://EDais.mvps.org/
imo, there's a time and place for both. TypeOf, since it requires 'Is' to
work, essentially returns only booleans.
TypeOf is much faster because the compiler "knows" ahead of time what you're
looking for. But that can bite you if you have a "favorite routine" that
includes tests for 3rd party components or ActiveX controls that don't exist
in the current project. TypeOf will bomb if the control type doesn't exist
in the current project.... which means you'll have several versions of that
"favorite routine" laying around.
TypeName is more generic. Yeah, it's slower but... we're not talking .Net
slower or anything ;-)
--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard -
http://www.vbsight.com/ComGuard.htm
In Loving Memory -
http://www.vbsight.com/Remembrance.htm