?
Solved

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

Posted on 2002-06-10
6
Medium Priority
?
453 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

765 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