Solved

Using COM Objects from VB.Net (Object Picker Dialog)

Posted on 2002-06-10
6
446 Views
Last Modified: 2013-11-25
Hi

I want to use the object picker dialog from VB.Net to populate a textbox with a group name. I've never used COM objects before and am having difficulty working out exactly what I need to do.

I found an article on MSDN, rather encouragingly called "Referencing COM Objects from Visual Basic .NET" , but found it very unclear and lacking in detail. I know that I have to import a type library and use the CoCreateInstance function, but I don't know how to find out where the type library is or how to use the function properly.

Please help!

Julia
0
Comment
Question by:JFaulkner
6 Comments
 
LVL 5

Expert Comment

by:rpai
ID: 7067010
To find the TypeLibrary, you could go to OLE View, and select Type Libararies opion.

You need to use:-
ObjectContext.CreateInstance("MyProj.MyClass")
to instanciate the COM object.

The following lines of code are required:-
Implements ObjectControl

Private objctxt As ObjectContext

Private Sub ObjectControl_Activate()
   Set objctxt = GetObjectContext
End Sub
Private Function ObjectControl_CanBePooled() As Boolean
End Function
Private Sub ObjectControl_Deactivate()
   Set objctxt = Nothing
End Sub

In the function where you need to instanciate the object.
objctxt.CreateInstance("MyProj.MyClass")

Hope this helps.
0
 

Author Comment

by:JFaulkner
ID: 7067239
Thanks for replying.

Sorry to ask such basic questions but I'm having difficulty applying your suggestions to my particular scenario (as you've probably gathered I don't don't have a huge amount of programming experience). I'm using IDsObjectPicker to browse active directory. This is part of ADSI and not a standard COM object.

I looked in OLE View but couldn't find anything relating to IDsObjectPicker. Also in your lines of code what should I substitute for ObjectContext, MyClass and ObjectControl; why do you have any empty function (objectControl_CanBePooled); and can I put all this stuff in a normal module ?

Thanks again

Julia
0
 
LVL 5

Expert Comment

by:rpai
ID: 7067454
Are you using VB or C++?

0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:JFaulkner
ID: 7069196
VB.Net
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7873487
Hi JFaulkner,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.

JFaulkner, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7924952
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now