Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving from VB6 to VB.net instrument handle?

Solved!
Go to solution

We develop instrument and their driver using ni-VISA. all our driver are DLL Based

and we call them in VB 6 : ( for example)

call  intrumentSomething(Visa Instrument Handle, someValu)

 

in VB6 we use to create a visa session  with viOpenDefaultRM this would give us a session unmber,

 then with this session number and the PXI or GPIB instrument ViOpen would give us an InstrumentHandle Number

 

this instrument number would be use for our own Driver and for the like of viOut16( InstrumentHandle,spacebar,ofset,data)

 

In Vb .net I found out to do a viout by NationalInstruments.VisaNS.RegisterBasedSession

then rbSession.Out16(spacebar,ofset,data)

this works fine no problem it is actualy quite nite.

 

Question How Do I retreive an insrument handle from .net for my already written drivers?

many thanks.

 

 

0 Kudos
Message 1 of 4
(4,425 Views)

Hi Lambda, 

 

Just to clarify, you have a driver written in VB6 and you wish to retrieve the instrument handle using VB.net?

 

Regards, 

Jas.W

Jason W.
Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 2 of 4
(4,388 Views)

Hi

DLL are win32 libraries written in C and they all use internally Vi calls like Viout16 or ViIn16 or Vi MoveIn all of then require the module Visa instrument handle as their first argument. 

My customer may use VB6 VB.net C or labview to write their own test application that use our PXI or GPIB instruments. I have not figured out yet how retrieve this instrument handle from the VisaNS class. ( if it is possible.)

thanks

 

0 Kudos
Message 3 of 4
(4,386 Views)
Solution
Accepted by topic author Lambda

FOUND IT...

This I think is the LINK between VisaNS and Visa32.dll

 

ALL VISA32 (old calls) use a ViSession number UInt32 in type.

 

With VisaNS the session is a CLASS but the Handle CAN be retreived:

Like this:

Imports NationalInstruments.VisaNS

Public MySession As PxiSession ' if you want PXI

Public MyOldViSession as UInt32

 MySession = CType(ResourceManager.GetLocalManager.Open(PXI::9::INSTR), PxiSession)

MyOldViSession = MySession.Handle

 

MyOldViSession is the instrument driver handle you need to act in the old ViInt16 or viGetAttribute of the old Visa32.dll

Note that this property does not pup up in vb.net list of available properties for this class you have to manually type it.

But it is listed in documentation.

 

when you are finished: MySession.Dispose()

Let me know if this help...

 

0 Kudos
Message 4 of 4
(4,335 Views)