Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

check control names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
stewart - 14 Sep 2007 01:31 GMT
I would like to be able to run a code that will check to see if a
control has a particular name and then tell me which one has that
name. I thought the code below would work but it does not do the
trick.

Private Sub btnSubmit_Click()

Dim C As Control
For Each C In Me.Controls
 If C.Name = "txtnum1" Then
   MsgBox C.Name
 End If
Next C

End Sub

Additionally is there a way to use a wild card.  For example show me
all textboxes that start with txtNum (txtNum1, txtNum2, etc)
Dave Peterson - 14 Sep 2007 01:55 GMT
It worked ok for me.

Maybe you need:

 if lcase(c.name) = "txtnum1" then

> I would like to be able to run a code that will check to see if a
> control has a particular name and then tell me which one has that
[quoted text clipped - 14 lines]
> Additionally is there a way to use a wild card.  For example show me
> all textboxes that start with txtNum (txtNum1, txtNum2, etc)

Signature

Dave Peterson

stewart - 14 Sep 2007 02:06 GMT
> It worked ok for me.
>
[quoted text clipped - 24 lines]
>
> Dave Peterson

that did the trick...now is there a way to change that so i can search
for a wildcard.  i want to find all textboxes that begin with txtNum
Dave Peterson - 14 Sep 2007 02:38 GMT
One way is to just look at the leftmost 6 chars:

if left(lcase(c.name),6) = "txtnum" then

> > It worked ok for me.
> >
[quoted text clipped - 27 lines]
> that did the trick...now is there a way to change that so i can search
> for a wildcard.  i want to find all textboxes that begin with txtNum

Signature

Dave Peterson

stewart - 14 Sep 2007 11:21 GMT
> One way is to just look at the leftmost 6 chars:
>
[quoted text clipped - 35 lines]
>
> Dave Peterson

thank you
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.