Instance

B

Bradley

I'm trying to access a driver by producing a instance to
it, so I can talk to a USB divice. It was originally
written in Visual Basic 5.0. And I'm using Visual C#_2002,
and have add the reference to the driver. Here is how it
looks in Visual Basic 5.0 and would like to see what it
would look like in Visual C#. This is just part of the
problem, but one thing at a time.

Any thoughts would be appreciate.

'Declare an object variable to hold the device collection.
'We use WithEvents so that we can utilize the OnChange event.
Private WithEvents Connected As BDAQ.BBDaqEnum
Attribute Connected.VB_VarHelpID = -1

'Declare an object variable to hold a device.
'We use WithEvents so that we can utilize the
OnDataAvailable event
'during timed sampling.
Private WithEvents Device1 As BDAQ.BBDaqDevice
Attribute Device1.VB_VarHelpID = -1
 
B

Bradley

-----Original Message-----
I'm trying to access a driver by producing a instance to
it, so I can talk to a USB divice. It was originally
written in Visual Basic 5.0. And I'm using Visual C#_2002,
and have add the reference to the driver. Here is how it
looks in Visual Basic 5.0 and would like to see what it
would look like in Visual C#. This is just part of the
problem, but one thing at a time.

Any thoughts would be appreciate.

'Declare an object variable to hold the device collection.
'We use WithEvents so that we can utilize the OnChange event.
Private WithEvents Connected As BDAQ.BBDaqEnum
Attribute Connected.VB_VarHelpID = -1

'Declare an object variable to hold a device.
'We use WithEvents so that we can utilize the
OnDataAvailable event
'during timed sampling.
Private WithEvents Device1 As BDAQ.BBDaqDevice
Attribute Device1.VB_VarHelpID = -1

I guess I missed line here it is

Set Connected = CreateObject("BDaq.BBDaqEnum")
'create an instance of BBDaqEnum and set it to the variable
 
D

Dmitriy Lapshin [C# / .NET MVP]

Bradley,

After you've added the reference to the driver, VS .NET has generated a so
called Interop assembly for you. This assembly contains wrappers enabling
you to access COM objects from managed code. The next steps for you will be:

1. Determine the namespace for the Interop assembly. You can find it out
with the Object Browser window inside the IDE, or with the ILDASM tool by
inspecting the assembly metadata. Most likely, the namespace will be the
same the name of the Interop assembly itself is.

2. Add a "using" statement with the namespace determined on step 1.

3. Add a "new" statement to the appropriate place in your code. This one
will probably look like this:

BBDaqDevice theDevice = new BBDaqDeviceClass().
 
B

Bradley

Thanks for the info, it's a good place to start,

Bradley
-----Original Message-----
Bradley,

After you've added the reference to the driver, VS .NET has generated a so
called Interop assembly for you. This assembly contains wrappers enabling
you to access COM objects from managed code. The next steps for you will be:

1. Determine the namespace for the Interop assembly. You can find it out
with the Object Browser window inside the IDE, or with the ILDASM tool by
inspecting the assembly metadata. Most likely, the namespace will be the
same the name of the Interop assembly itself is.

2. Add a "using" statement with the namespace determined on step 1.

3. Add a "new" statement to the appropriate place in your code. This one
will probably look like this:

BBDaqDevice theDevice = new BBDaqDeviceClass().

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Bradley said:
I'm trying to access a driver by producing a instance to
it, so I can talk to a USB divice. It was originally
written in Visual Basic 5.0. And I'm using Visual C#_2002,
and have add the reference to the driver. Here is how it
looks in Visual Basic 5.0 and would like to see what it
would look like in Visual C#. This is just part of the
problem, but one thing at a time.

Any thoughts would be appreciate.

'Declare an object variable to hold the device collection.
'We use WithEvents so that we can utilize the OnChange event.
Private WithEvents Connected As BDAQ.BBDaqEnum
Attribute Connected.VB_VarHelpID = -1

'Declare an object variable to hold a device.
'We use WithEvents so that we can utilize the
OnDataAvailable event
'during timed sampling.
Private WithEvents Device1 As BDAQ.BBDaqDevice
Attribute Device1.VB_VarHelpID = -1

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top