View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default Identifying a Control Type

Hi Arne,

This section from the help topic on the If...Then...Else statement
describes the TypeOf operator:

An expression of the form TypeOf objectname Is objecttype. The objectname is
any object reference and objecttype is any valid object type. The expression
is True if objectname is of the object type specified by objecttype;
otherwise it is False.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Arne" wrote in message
...
I was not aware of the operator(?) TypeOf. Even though VBA
does consider it legal, I cannot find any help on it, and,
what's more, it did not work in an example I had a look at
(identifying a check box control on a form). It may depend
on the sofware versions, I don't know. The following did
work:

Dim c As Control

For Each c In UserForm1.Controls
if TypeName(c)="TextBox" then
some code
Next c