473,320 Members | 2,054 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How do I create a com object?

I have a simple atl com object which I created with visual C++.
In vb6 there was two ways to use this object. 1. I could add
it as a componenet, and then it appered on the toolbox, and
2. I could add it as a reference, and then use CreateObject
in runtime. Please explain how this has changed for .net.
Nov 21 '05 #1
5 928
Right click your toolbox and choose Add/Remove Items. From the Customize
Toolbox dialog, select the COM tab. Locate your COM component, if it is
registered on the system, and choose Ok, The component should now appear in
your toolbox. .NET will create the necessary wrappers for you and you can
now use the component in your code.

If you do not see your component listed in the available components, choose
Browse to locate the item on your hard drive.

--
Gerry O'Brien
Visual Basic .NET MVP
"Andy" <a> wrote in message news:es**************@TK2MSFTNGP15.phx.gbl...
I have a simple atl com object which I created with visual C++.
In vb6 there was two ways to use this object. 1. I could add
it as a componenet, and then it appered on the toolbox, and
2. I could add it as a reference, and then use CreateObject
in runtime. Please explain how this has changed for .net.

Nov 21 '05 #2
How do I respond to events ?
Nov 21 '05 #3
"Andy" <a> wrote in news:Ol**************@TK2MSFTNGP14.phx.gbl:
How do I respond to events ?

Assume you have a com object named ABC.

Then you would go:
Private Sub EventHandler(Byval sender as object, Byval e as eventargs)
handles ABC.SomeEvent

End Sub
Byval sender as object, Byval e as eventargs depends on the obeject you're
handling the event for - different events may have different parameters.

Also, make sure you declare ABC withevents as:

Private WithEvents ABC as SomeComObject

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #4

I did it differently, I used

Dim mycom As New paLib.o1
AddHandler mycom.yy, AddressOf event1
..
..
..

Sub event1()
MsgBox("ev")
End Sub

Didn't dim "withevents", but it *did* work, maybe you know why.

Thanks
Andy.

How do I respond to events ?

Assume you have a com object named ABC.

Then you would go:
Private Sub EventHandler(Byval sender as object, Byval e as eventargs)
handles ABC.SomeEvent

End Sub
Byval sender as object, Byval e as eventargs depends on the obeject you're
handling the event for - different events may have different parameters.

Also, make sure you declare ABC withevents as:

Private WithEvents ABC as SomeComObject


Nov 21 '05 #5
"Andy" <a> wrote in news:OA**************@TK2MSFTNGP11.phx.gbl:
I did it differently, I used

Dim mycom As New paLib.o1
AddHandler mycom.yy, AddressOf event1
.
.
.

Sub event1()
MsgBox("ev")
End Sub

Didn't dim "withevents", but it *did* work, maybe you know why.


It's basically the same thing - you explicitly created an event handler in
code.

Eiher method works fine - it depends on which method you prefer. AddHandler
does have one advantage, it allows you to dynamically create event handlers
during runtime.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class...
9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Just D. | last post by:
All, Do we have a simple way to Create an object on the fly knowing just an object type? The usual design-time way is to write a code something like this: CObjectType obj = new CObjectType();...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
2
by: Big Charles | last post by:
Hello, I would like to create an array-class to be able to call like: Dim oMyCar as New MyCar ' After initializing oMyCar, the object has to be like: oMyCar(0).Brand...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.