?
Solved

Does anyone know how to list Public Procedures at runtime?

Posted on 2003-03-14
7
Medium Priority
?
152 Views
Last Modified: 2010-04-07
Hi,
I am building an ActiveX control that allows the user to specify a Public Function or Sub Routine that can be called when the control's Calculate method is called.

The functions/sub routines are stored in a seperate class and the CallByName method is used
to call them.

I would ideally like to list all of the available Public procedures in a combo box on a Property Page so it is only possible to select a valid procedure name. I have no idea how to do this in Visual Basic 6.

Can anyone help!?
0
Comment
Question by:joboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:bob_online
ID: 8137995
VB isn't going to automatically do this for you.  You're going to have hard code names to load into the combo box.  I like the idea, though
0
 
LVL 4

Expert Comment

by:JohnChapin
ID: 8138176
Shouldn't the list of names be a property of the class itself?  Just to keep the object orientation.
0
 
LVL 5

Author Comment

by:joboy
ID: 8138314
I had wondered whether or not I should add a dynamic property that would expose a collection of Procedure Names. Where the procedure names are hardcoded into the class.

I'm not too keen on doing it this way because the class contains around 40 procedures.  Each procedure in the class carries out a specific calculation (the control I'm building is kind of like Excel but designed for a specific task). Not only this it is highly likely that people will decide that calculations need adding/changing.  This means the hardcoded procedure names must be kept up to date (a pain!).

Anyway... I'm presuming that as the Object Browser can list procedures etc., there must be a way of doing it. Maybe an API call or something!?

Cheers for the help so far..
Joseph
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:Hermetic
ID: 8139063
Possibly, the solution lies in the CodeModule object's
property Members (a collection of Member objects).
0
 
LVL 1

Expert Comment

by:hazgod
ID: 8140066
why not store the names in an array, which can be added to. then populate the listbox with the names from the array
0
 
LVL 5

Accepted Solution

by:
joboy earned 0 total points
ID: 8142316
Cheers for the help so far...
I have found a possible solution to the problem... I've added a reference to the TLBInf32 dll to my project and using this I seem to able to obtain the info I require. Here's the sample code below...

Sub Test()
    Dim t As New TLI.TLIApplication
    Dim typInfo As TLI.TypeInfo
    Dim memFo As TLI.MemberInfo
    Dim interface As TLI.InterfaceInfo
   
    'MsgCentre1 is just a ActiveX usercontrol I created
    'myself and added as a component to my project, so
    'I had something to reference
    Set typInfo = t.ClassInfoFromObject(MsgCentre1)
    For Each interface In typInfo.Interfaces
        For Each memFo In interface.Members
            If memFo.InvokeKind = INVOKE_FUNC Then
                Debug.Print memFo.Name
            End If
        Next
    Next
   
    Set interface = nothing
    Set typInfo = Nothing
    Set memFo = Nothing
    Set t = Nothing
End Sub

The only problem I'm having with the code now is that it seems to be listing additional functions (presumably created internally by VB) alongside my functions...

Anyone know how to correct this problem?

P.s. The CodeModule solution I pretty sure is specific to the VBE object (i.e. Microsoft Office VBA) and works on non-compiled visual basic.
0
 

Expert Comment

by:CleanupPing
ID: 8900082
joboy:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question