Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2002-06-10
6
Medium Priority
?
456 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
[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
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Suggested Courses

604 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