Solved

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

Posted on 2002-06-10
6
443 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

863 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

21 Experts available now in Live!

Get 1:1 Help Now