Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a VISA driver for vb.net yet?

My VISA version 2.6 does not work with vb.net.
Is there a VISA for vb.net?
0 Kudos
Message 1 of 17
(6,326 Views)
Boonton:

I realize that we do not yet have a native .NET VISA solution, but we are working on one. You can read more about our .NET initiatives on this web page:

http://digital.ni.com/express.nsf/bycode/exvprz?opendocument〈=en&node=seminar_US

And you can sign up to become a beta tester for a future version of Measurement Studio by contacting mstudio.beta@ni.com

I am interested to know what you mean when you say it does not work. Until we have complete .NET support, there are several ways you can use NI-VISA 2.6 within VB.NET.

First, if you have ComponentWorks, our VISA ActiveX control should work very well in .NET. Second, we embed a type library into our visa32.dll that you should be able to call directly. Third, we ship a VISA COM
API - try starting with the ResourceManager class in \VisaCom\GlobMgr.dll. Admittedly, that API is undocumented in this release but each call corresponds to a VISA C call. Finally, we still ship a visa32.bas file in \WinNT\include. As a last resort, you can use this to make direct calls into the NI-VISA library.

Dan Mondrik
Senior Software Engineer, NI-VISA
National Instruments
0 Kudos
Message 2 of 17
(6,326 Views)
Hello Dan:I am trying to use the Niglobal.bas and Vbib-32.bas files in VB.net environment,they do not work.It seems that VB.net has a problem with the "As Any" declarations.Will you provide some new files to work in the .Net Environment?
thanks: Robert Cottiers, Boonton Electronics
bcottiers@hotmail.com
0 Kudos
Message 3 of 17
(6,326 Views)

Actually you can use the VISA class I posted in C#.


One of the nice things about the whole .NET platform is that all the languages share a common type system, common calling conventions, etc... So you can create instances of classes written in C# from within VB.


I will attach a generic instrument class that I wrote in C#. it provides an address property and write and query capability.


Message 4 of 17
(6,326 Views)
Do you have a VB.net example program which uses the C#
instrument class?.I tried to transcribe your sample project in C# into VB.net,with not too much success.If you could show how you create an instance of your class in VB it would be helpful. Thanks
0 Kudos
Message 5 of 17
(6,326 Views)

It is evidently not as easy as Microsoft says it is. Imagine that!

VB.NET does not natively support the usigned integer types very well, but with a little effort I was still able to use my C# class rather nicely.

Of course if you use the conversion wizard on the old visa.bas then overload the functions which used the old as any type it will be pretty simple.

0 Kudos
Message 6 of 17
(6,326 Views)
I tried to load your example program"Using visa.cs in VB.net".When I open the project in vb.net with "WindowsApplication1.sln",I receive an error message "Unable to read the project file visa.csproj",The system cannot find the path specified.Any suggestions?
0 Kudos
Message 7 of 17
(6,326 Views)
I needed to do this anyway for some of the guys here. I just imported the old visa32.bas and made a few changes. I also ported my CInstrument class to Vb.NET.
You should be able to easily derive all your instruments from this class.
Sorry for all the trouble with this, I have the Visual Studio Enterprise Architect, and there must be some differences between it and whatever you have.
This is untested, so you might have to fiddle around with the formatted and buffered I/O commands. But everything else should work without modification.
0 Kudos
Message 8 of 17
(6,328 Views)
Thanks for all your help,Everything works fine now.Have you done any work with Asp.net applications?.It would be nice to take your program and make it accessible on an intranet/internet.
0 Kudos
Message 9 of 17
(6,328 Views)
saikey,
Thanks for your C# class. I have been using it with several C# applications I have written. I had to change the 'System.String desc' parameter to accept a byte pointer to get the viStatusDesc function to work properly. I changed it to:
[DllImport("visa32.dll")] public static extern
System.Int32 viStatusDesc (System.UInt32 vi, System.Int32 status,[MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer);

I can't seem to get the vi events and vi event handlers working and was wondering if you could provide an example of this?

Thanks again!
0 Kudos
Message 10 of 17
(6,057 Views)