VB search for a control

Hi All,

Is there anything in VB which lets me search the whole of the project to 
find out which forms have a certain control.

ie.,  if i wanted to find out which forms have a PictureBox1  can that be 
done?   It would be no good searching the actual code, as it wont have any 
associated with it.

Thanks



0
Jack
1/6/2010 4:15:29 PM
vb.general.discussion 1016 articles. 0 followers. Follow

12 Replies
918 Views

Similar Articles

[PageSpeed] 25

"Jack Rabbitt" <a@b.com> wrote in message 
news:tG21n.18364$H15.676@en-nntp-02.dc1.easynews.com...
>
> ...  It would be no good searching the actual code, as it wont have any 
> associated with it.
>

Not quite true. A text search of all your FRM files will show

    Begin VB.PictureBox PictureBoxName

for every instance of the control, even if no code is under its events.

If (based on your description) you actually wanted to find a named 
PictureBox control (like PictureBox1 you mention), you can search for that 
as well.

-- 
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net


0
Rick
1/6/2010 4:25:23 PM
If this is a one time need, then you could add a Module to your project and 
put this code in it...

Sub FindControls()
  Dim N As String, F As Form, C As Control
  Form1.Show vbModeless
  Form2.Show vbModeless
  Form3.Show vbModeless
  Form4.Show vbModeless
  N = InputBox("What control name are you looking for?")
  For Each F In Forms
    For Each C In F.Controls
      If LCase(C.Name) = LCase(N) Then Debug.Print F.Name
    Next
    Unload F
  Next
End Sub

Make sure you Show include a Show statement that shows every form in your 
project modelessly as I have done for my four example Forms in the above 
code. Then put a CommandButton on the first form you show (or in Sub Main if 
you start your project that way) and call the above Sub from its Click 
event. Run the project and click the CommandButton you added. It will ask 
you for the control name you want to search for and then display the Form 
names for each form containing a control with that name in the Immediate 
Window. You can embellish this code as needed (add a loop so you can search 
for multiple controls, change the output location from the Immediate Window 
to a file, etc.). Once you no longer need to do any searching, delete the 
CommandButton and Module you added and your project is back to the way it 
was when you started.

-- 
Rick (MVP - Excel)


"Jack Rabbitt" <a@b.com> wrote in message 
news:tG21n.18364$H15.676@en-nntp-02.dc1.easynews.com...
> Hi All,
>
> Is there anything in VB which lets me search the whole of the project to 
> find out which forms have a certain control.
>
> ie.,  if i wanted to find out which forms have a PictureBox1  can that be 
> done?   It would be no good searching the actual code, as it wont have any 
> associated with it.
>
> Thanks
>
>
> 

0
Rick
1/6/2010 5:01:44 PM
"Jack Rabbitt" <a@b.com> wrote in message 
news:tG21n.18364$H15.676@en-nntp-02.dc1.easynews.com...
> Hi All,
>
> Is there anything in VB which lets me search the whole of the project to 
> find out which forms have a certain control.
>
> ie.,  if i wanted to find out which forms have a PictureBox1  can that be 
> done?   It would be no good searching the actual code, as it wont have any 
> associated with it.

As Rick Raisley suggested, you can search the source files using external 
tools(not in the IDE). Also, Explorer's Search for Files and Folders doesn't 
search VB files because it only recognize certain extensions as being text 
files, so if you use it, you will find nothing. So use another search tool. 
Here is a free fast one:

http://freesoftland.sytes.net/ssearch3.html


0
Nobody
1/6/2010 5:32:20 PM
"Nobody" <nobody@nobody.com> wrote in message 
news:efvfJZvjKHA.2188@TK2MSFTNGP04.phx.gbl...
>
> Also, Explorer's Search for Files and Folders doesn't search VB files 
> because it only recognize certain extensions as being text files, so if 
> you use it, you will find nothing.
>

I didn't realize that. I use Total Commander for file viewing, searching and 
a lot more, and it works very well for that purpose. Our programmers, in 
fact, used to use a custom application for such things, but found Total 
Commander so customizable that it did everything for them.

http://www.ghisler.com/

Imagine the old Norton's Commander, but updated and expanded for Windows. 
;-)

-- 
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net


0
Rick
1/6/2010 8:51:14 PM
"Nobody" <nobody@nobody.com> wrote in message 
news:efvfJZvjKHA.2188@TK2MSFTNGP04.phx.gbl...

> Also, Explorer's Search for Files and Folders doesn't search
> VB files because it only recognize certain extensions as being
> text files, so if you use it, you will find nothing. So use another
> search tool.

Actually that is just the default condition. You can set up Windows 
Explorer's Search options so that it does in fact search the contents of VB 
..frm and .bas (etc) files. You can do this by modifying the registry in both 
XP and Vista (by adding or modifying a PersistentHandler key under the 
specific file type's entry in HKEY_CLASSES_ROOT) or you can do it using the 
dialog in Explorer's Search window. For example, to do it in Vista start a 
Search and then click the Advanced search link. Under Search Tools select 
Modify Index Locations and then click the Advanced button followed by the 
File Types tab. Scroll to the entry for the extension "frm" and click it to 
select it. Place a tick in the box against it (if there isn't a tick already 
there) and then select the Index Properties and File Contents option button. 
The entry for the extension "frm" should now have a little tick in the box 
and the words "Plain Text Filter" against it. Then OK out of the dialogs. As 
far as I recall you need to restart your system for the settings to take 
effect, whether you do it using the Registry or using the method I have just 
outlined.

Mike


0
Mike
1/7/2010 10:57:03 AM
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message 
news:e6b99HxjKHA.5520@TK2MSFTNGP06.phx.gbl...

>> Also, Explorer's Search for Files and Folders doesn't search VB files 
>> because it only recognize certain extensions as being text files, so if 
>> you use it, you will find nothing.
>>
>
> I didn't realize that.

It was introduced in XP. 


0
Jeff
1/7/2010 3:23:16 PM
In article <eMrNX16jKHA.4672@TK2MSFTNGP06.phx.gbl>, i.get@enough.spam 
says...
> 
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message 
> news:e6b99HxjKHA.5520@TK2MSFTNGP06.phx.gbl...
> 
> >> Also, Explorer's Search for Files and Folders doesn't search VB files 
> >> because it only recognize certain extensions as being text files, so if 
> >> you use it, you will find nothing.
> >>
> >
> > I didn't realize that.
> 
> It was introduced in XP. 

NT and 2000 had it as well, though the steps for enabling it were 
different.

D

0
David
1/7/2010 3:31:12 PM
"Jeff Johnson" <i.get@enough.spam> wrote in message 
news:eMrNX16jKHA.4672@TK2MSFTNGP06.phx.gbl...
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message 
> news:e6b99HxjKHA.5520@TK2MSFTNGP06.phx.gbl...
>
>>> Also, Explorer's Search for Files and Folders doesn't search VB files 
>>> because it only recognize certain extensions as being text files, so if 
>>> you use it, you will find nothing.
>>>
>>
>> I didn't realize that.
>
> It was introduced in XP.

Which was when I wrote my own file search utility since Windows was 
obviously heading down a path of preventing anything actually useful.

0
Bob
1/7/2010 4:08:57 PM
"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:uZSang4jKHA.4672@TK2MSFTNGP06.phx.gbl...
> "Nobody" <nobody@nobody.com> wrote in message 
> news:efvfJZvjKHA.2188@TK2MSFTNGP04.phx.gbl...
>
>> Also, Explorer's Search for Files and Folders doesn't search
>> VB files because it only recognize certain extensions as being
>> text files, so if you use it, you will find nothing. So use another
>> search tool.
>
> Actually that is just the default condition. You can set up Windows 
> Explorer's Search options so that it does in fact search the contents of 
> VB .frm and .bas (etc) files. You can do this by modifying the registry in 
> both XP and Vista (by adding or modifying a PersistentHandler key under 
> the specific file type's entry in HKEY_CLASSES_ROOT) or you can do it 
> using the dialog in Explorer's Search window. For example, to do it in 
> Vista start a Search and then click the Advanced search link. Under Search 
> Tools select Modify Index Locations and then click the Advanced button 
> followed by the File Types tab. Scroll to the entry for the extension 
> "frm" and click it to select it. Place a tick in the box against it (if 
> there isn't a tick already there) and then select the Index Properties and 
> File Contents option button. The entry for the extension "frm" should now 
> have a little tick in the box and the words "Plain Text Filter" against 
> it. Then OK out of the dialogs. As far as I recall you need to restart 
> your system for the settings to take effect, whether you do it using the 
> Registry or using the method I have just outlined.

There are other extensions like ".bas", ".ctl", ".vbp", so it's too much 
work. I prefer to use another tool. Also, Search for Files and Folders 
downloads an XML file from a Microsoft server without my consent.



0
Nobody
1/7/2010 5:05:09 PM
"Nobody" <nobody@nobody.com> wrote in message 
news:%23ZPxou7jKHA.4672@TK2MSFTNGP06.phx.gbl...

>>> [Nobody said] Also, Explorer's Search for Files and Folders
>>> doesn't search VB files because it only recognize certain
>>> extensions as being text files, so if you use it, you will find
>>> nothing. So use another search tool.
>>
>> [Mike Williams said] Actually that is just the default condition.
>> You can set up Windows Explorer's Search options so that it
>> does in fact search the contents of  VB .frm and .bas (etc) files.
>> You can do this by . . . . . [snip]
>
> There are other extensions like ".bas", ".ctl", ".vbp"

Yes, of course there are. In fact I already mentioned .bas in the post to 
which you are responding. I mentioned .frm and .bas files in my response 
purely as an example.

> so it's too much work. I prefer to use another tool.

That's fine. If setting up your machine just once is too much work for you 
then don't do it. I was merely pointing out that, contrary to what most 
people would be led to believe when reading your own response, the Windows 
Explorer search engine can recognise and search lots of files, not just text 
files, and that it will happily search your VB .frm, .bas and other files if 
you set it up properly, as explained in my own response.

> Also, Search for Files and Folders downloads an XML
> file from a Microsoft server without my consent.

Well complain to Micro$oft about it. Lots of stuff in Micro$oft Windoze does 
things behind your back. They're a bunch of insidious b_a_s_t_a_r_d_s, so 
why don't you tell 'em so if you're so concerned about it. Pointless 
complaining to me about them . . . I already hate them!

Mike




0
Mike
1/7/2010 6:10:13 PM
> Pointless complaining to me about them . . . I already hate them!

ROTFLMAO

-- 
Rick (MVP - Excel)
0
Rick
1/7/2010 6:43:45 PM
"David Kerber" <ns_dkerber@ns_warrenrogersassociates.com> wrote in message 
news:MPG.25afc8477ad9f0fe9896a4@news.conversent.net...

>> >> Also, Explorer's Search for Files and Folders doesn't search VB files
>> >> because it only recognize certain extensions as being text files, so 
>> >> if
>> >> you use it, you will find nothing.
>> >>
>> >
>> > I didn't realize that.
>>
>> It was introduced in XP.
>
> NT and 2000 had it as well, though the steps for enabling it were
> different.

Okay, I have to ask for a cite on this one. I'm virtually positive that 
everything before XP searched all file types when you searched for text. 


0
Jeff
1/7/2010 6:59:50 PM
Reply:

Similar Artilces:

Searching the information store
Is there a way to search the information store to find out if anyone has sent a message to a particular outside email address? I need to see if any of my company employees has sent an email to a particular location. On Mon, 30 Oct 2006 11:38:02 -0800, ghutnick <ghutnick@discussions.microsoft.com> wrote: >Is there a way to search the information store to find out if anyone has sent >a message to a particular outside email address? I need to see if any of my >company employees has sent an email to a particular location. Message tracking. Could you be more specific? How...

Open forms in single 'tab control' window
Hi, I have got forms and subforms created for my application. Several forms have command buttons which open yet other sub-forms, however, each form opens in a new window whether the main ones or subforms. To make a better interface, is it possible that whenever one clicks on a command button, it opens the form in a 'tab control' window. Not to confuse the tab control for tabbing as I want to use only 1 tab control window only because it looks neaterto have my forms open in there. So in all, it's like having a menu of command buttons now that I have made and when you click ...

search for a particular string in cells
Is there any function which will search for a specific combination of letters in a range of data. Say data is in column A(A1 to A1000). How to find how many cell entries are having "atd" pattern in them. Order is fixed, but the letters may be at stat, end or mid of the entire string in the cell thanks One way... =COUNTIF(A1:A1000,"*atd*") Note that this is not case sensitive. That formula will evaluate "atd" and "ATD" as being equal. -- Biff Microsoft Excel MVP "hsg" <hsg@discussions.microsoft.com> wrote i...

VB distmon?
Hi I have recently installed Office 2003. A couple of wired things happen in Excel: > Everytime I close the program I get a MS VB error that reads "Compile error in hidden module: Distmon" Every time open the program I get the same error, but the macro it is calling is "autoexecnew" > Since my new installation, I type in an simple function like TRIM and it tells me cannot find project library. any ideas? Thnaks! Alan Alan http://support.microsoft.com/default.aspx?scid=kb;EN-US;q307410 OFF: "Compile Error in Hidden Module" Error Message When You Sta...

Alternative to Calendar Control 8.0
I noticed that the Active X Calendar Control 8.0 control is not currently installed on my machines at work, and for now I am assuming that I will NOT be allowed to install it at my highly secure workplace. (I couldnt find it anywhere in the "Additional Controls" area) So.... Does anybody have any bright ideas on how to implement something similar to a calendar control?? I just want an easy way for my users to select a date. Right now we are simply typing a date in a target cell, but I thought it would be nice if we could select dates in a more flexible manner. The...

Forensic search in Exchange2000
I have a request to search a user's mailbox for the past year for an email. Can this be accomplished by administration tools available from Microsoft or do I need to purchase added software? If so, can you help me with information on how I can accomplish this task? Thanks, Debra I was not clear on search. The request is to research an mailbox for email correspondence trail to other users. Thanks "Debra" wrote: > I have a request to search a user's mailbox for the past year for an email. > Can this be accomplished by administration tools available from Microsoft ...

Excel VB
I have two cells in a workbook that are dates. The cell Start_Date has a valid date in it. The second cell Test_Date is either blank or has a valid date in it. The IsDate test on both cells works fine, however, on a blank cell the Month function extracts "12". Anyone know why? I had to put the month function within a test for IsDate to make it work. Seems like Month function on a blank cell should return something other than a 12. Dave Test code: If IsDate(Range("Start_Date")) Then 'Cell has 11/01/09 in it. MsgBox ("start date a d...

Queries
I have created an Access database (2003) that contains information about the status of specific projects our office is working. There is only one table and the database contains the names of about 30 employees. Each employee is assigned specific work and required to input dates regarding the status of each part of the overall process (there are about 5 pieces). Is it possible to create a query where I input the employee's name and a single date criteria (i.e. between 6/13/07 and 6/20/07) and Access will search across multiple fields to return the requested information? For insta...

Cannot Add any window to VB
Hello: I'm using a VM with GP 10.0 SP3 installed. In order to have the same as our production databases i copy the GP folder, entirely, which i think it was a mistake now I'm getting a "This cannot be added to Visual Basic", whenever i try to add a window, any window, to VB. Also it goes without saying that there's a lot of load errors starting GP. For the record the copy/paste thing worked, sort of, and before you start thinking that i was insane to have done this, there's a reason behind it, There's been a lot of tweaks to our production server, by our p...

Search photos without specific tag in Photo Gallery
Hello! Is it possible to exclude photos with specific tag from search results? For example I want to search for all photos that are tagged "animal" but want to exclude photos with tag "cat". I've tried search queries like "animal -cat" but that does not seem to work. Any ideas? P.S. I'm using Vista SP2 Home Premium Photo Gallery -- Veld ...

Wordwrap Edit Control
My app allows the user to check a short txt or log file. The text file size is less than 100 characters, maybe less than 50. It reads the file to a character array and I use SetDlgItemText to put in into the Edit control. Is there a way to using the Edit control settings to wordwrap text? I know I can work around it by breaking up the character array (or CString) writing lines that will fit. Or I can use a messagbox which will wrap. Thanks in advance for any ideas. folderann schrieb: > Is there a way to using the Edit control settings to wordwrap text? Use ES_MULTILINE without ...

How to stop highlighting items in Cedit control
I am using a Cedit control within a propertypage to display a list of status messages as the program executes a series of actions. Everything works OK, except that all of the text in the Cedit control is highlighted (selected?). Is there a way to insert data into the Cedit control without having the text highlighted? Call SetSel(-1,0) for the edit control to deselect the text. You can do this in an update routine. Tom "Brian Westcott" <bwestcott@shaw.ca> wrote in message news:%237U9muIlGHA.1320@TK2MSFTNGP04.phx.gbl... >I am using a Cedit control within a propert...

search a matrix for values
OK, this is a bit of a tricky problem.... i have a 7*7 matrix in excel, which is full of numbers... i want to search in only half the matrix, where half is from cell1-1, to cell 7-1 (i.e. top left to bottom right). what i want to search is for numbers a certain value, say X. what i then want to do is tablulate these numbers in one column, and then tablue late their position as a reference to the matrix (i.e. their matrix position). how on earth can i do this? Phil I have assumed that the matrix is in A1:G7 In A10 I entered =INDEX($A$1:$H$7,ROW(A1),ROW(A1)) and copied down to A16 In...

vb from VC++
Hi, is it possible, and if so, to call a Vb macro from VC++. Or manipulate spreadsheets (ie draw graphs from the data within the workbooks) usinbg MFC functions cheers Anthony Presumably you are referring to MS Excel spreadsheets and workbooks. The easiest method would be to import the appropriate type library (.tlb) provided with Excel, having the class wizard generate the classes, which you then use to access the Excel Automation model (that is the same model that Excel VBA uses). Some investigation may be needed to determine which tlb to use, and to make sure you have a basic understand...

COMMENTS ON NTOSKRNL.EXE missing AND WINDOWS SEARCH
Something odd is going on with my ability to receive responses to these 2 posts. A very kind MVP noticed that I was not reading the responses and sent me an email directly. He tells me there are indeed responses to my posts. I am not able to see them even after refreshing, restarting the news group, getting next headers, etc. He has also sent me some links to look at and I will do that very soon. I want to thank everyone who has replied and assure you that I am not ignoring your replies. I simply cannot see them. I'd ask for your help in figuring out why I can'...

Controlling initial FormView size
I have an MFC application which on startup opens multiple FormViews in ChildFrames. An annoyance I am having is that as they open up, the Views' sizes bear very little resemblance to underlying dialog resources. They are always either too big or too small in at least one direction, and need to be resized. Not a show stopper, but an annoyance. What is a good way to control the initial size of these windows? Thanks, Henryk Birecki You could try doing this code that will resize controls and the dialog and save the settings based on user interaction: http://www.codeproject.com/KB/dialog/re...

VB in Excel
In Excel I go into Visual Basic Editor, then Visual Basic Help, but when I type 'Passwords' for example it will bring up a list of related items, but some of them you can't select. Does this mean the installation CD is corrupt and hasn't installed all the components? I have reinstalled and repaired the installtion but to no avail. Any ideas anyone? Help! Thanks ...

VB.Net program to create XML file
I need to create an xml file from a VB program using fields returned from an sql query. I have a template that was provided for me and need to use verbatim. Since this is just a text file, I gather that I can just write out the file with all of the tags, etc., and name it .xml. Assuming that is correct what I might want to do is create a template so that if this file changes the names of the elements, all I have to do is change the template and if more elements get added I can then add them. Is there a tool that can do this for me? If I have to create one, any suggestions as to what I ...

When searching this type of folder, you can't search other folders at the same time
Hi, I have a user that is trying to use Advanced Find to search another users mail box for and e-mail in Outlook 2000 Sp3. When the user selects the browse button to select more than one directory to search, the following error message appears "When searching this type of folder, you can't search other folders at the same time". Also, if a top directory is selected, Advanced Find does not do a recursive search, but only searches the selected directory. The user has the owner role assigned to the folders in question, so I don't think that's it to do with permissions....

VB++ Exe zum Ansprechen einer VB ActiveX DLL
Hallo zusammen. Ich ben�tige eine EXE, welche in einer DOS-Box mit Parametern aufgerufen wird und das Ergebnis auch wieder in dieser DOS-Box zur�ckbringt. Mit VB ist dies leider nicht zu machen. Nun weiss ich zwar das dies mit einer VC++ Exe geht, bin aber leider C Neuling. Kann mir dazu jemand ein Beispiel posten ? Die C++ Exe soll einen auf der Commandozeile �bergebenen String (das sind die ganzen Parameter) an eine Funktion einer VB ActiveX DLL �bergeben. Das Ergebnis soll dann von der ActiveX DLL an die C++ Exe zur�ckgegeben werden und in der selben DOS-Box angezeigt werden. Hoffe es k...

List Control Box in MFC
I am working on making a control box with MFC and I have a CStringArray in which I have all the file names stored.. Can anyone help me with where i can find code for making the controlbox. thanks in advance UMR_Smoker Do you mean a ListBox? What code? Why not use the resource editor to insert a ListBox. You can populate it using CListBox::AddString in OnInitDialog(if its a dialog app). ----------- Ajay Kalra ajaykalra@yahoo.com UMR_Smoker wrote: > I am working on making a control box with MFC and I have a CStringArray > in which I have all the file names stored.. Can anyone help ...

VB Script
Hi all, I need a VB script code to verify whether a specific Local user ID on a remote machine, in workgroup, is having a specific password. For instance I need to check whether target machine consists a local user "DSADMIN" 's password set to "Pa55word". If the target machine consists this user account and the password is also correct then it should return TRUE else it should return FALSE (or something similar). Below code tries to reset the password on target machine by providing same old and new password, if it fails that means the password set on target...

search macro with array
Hello. 3rd try, hope this post goes through. Using Excel X for Mac. Need a macro to search column Q for a list of stock ticker symbols for funds owned. When one is found, highlight that row and shade it light green. Thought I would make my first try at an array and cobbled together the macro below. It doesn't crash or return error messages but it also doesn't work. Stepping through it I noticed it dumps out of the Do loop after nine cycles and there are 9 fund names in the list (array). Could be a clue, but to what I don't know. Any help would be appreciated. Sub NLF...

Sumproduct in VB
I want to be able to use the sumproduct function in code to calculate some fairly complex formulas. Within the sumproduct function I'm trying to use a selection critera. The range "Wave" is a named range. This works fine in a regular worksheet function. It multiplies the cells in columns A and B where Wave = 2. =sumproduct(--(Wave=2),$A$1:$A$100,$B$1:$B$10) In VB I have the function below, which surprisingly works just fine as written. For now ignore X... Function mytest(X as Variant, rng1 as Variant, rng2 as Variant) as double mytest = Applicatio...

Search Account Error.
Another strange behaviour occured today. User try to search accounts starting with "am" CRM displays an error message that error encounters etc. while if user give any other letters as search criteria, it worked fine. even If user try to go to Page 2 of list page. it also give the same error because 2nd page has account names starting with am. It doesnot looks logical but It is occuring. I restarted the machine and verified it several time and same behaviour. Regards, BizWorld. Something is strange with your CRM environment. Search account starting with "am" di...