Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Get any/all VISA-USB Addresses

Solved!
Go to solution

VisaNS was the legacy .NET API for VISA that NI developed several years ago. While it is still supported, for new applications we suggest the use of NationalInstruments.Visa API that is an implementation of the IVI standard VISA .NET API.

 

Unlike in VisaNS where ResourceManager provided static method to get the local ResourceManager on which you would call the Find method, in the new API, you would create a new object of the ResourceManager class and then call the Find method on that object. Please see the NI-VISA .NET Help that is installed on your system for more details. You can get to it from the start menu (All Programs >> National Instruments >> NI-VISA >> NI-VISA Documentation).

0 Kudos
Message 21 of 24
(1,201 Views)

Hope is restored. How about an example (in VB.NET)?

0 Kudos
Message 22 of 24
(1,198 Views)
Solution
Accepted by topic author BiggyD

There are several c# based examples installed here (which can be reached from All Programs >> National Instruments >> NI-VISA >> Examples):

C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\.NET\

 

I took a snippet from the find resources example and converted to VB.NET and used a different search string of the form "USB?*" because you are interested in finding USB resources.

Imports System
Imports System.Collections.Generic
Imports Ivi.Visa
Imports NationalInstruments.Visa

Module Module1
    Sub Main()
        Using rm = New ResourceManager()
            Try
                Dim resources As IEnumerable(Of String) = rm.Find("USB?*")
                For Each s As String In resources
                    Dim parseResult As ParseResult = rm.Parse(s)
                    System.Console.WriteLine(s, parseResult.InterfaceType)
                Next
            Catch ex As Exception
                System.Console.WriteLine("Exception" + ex.Message)
            End Try
        End Using
        System.Console.ReadLine()
    End Sub

End Module

Hope this helps.

 

 

 

Message 23 of 24
(1,193 Views)

Uh,oh.... You did it!  You're my hero!  Now get NI to put it in their manual.

Good job. Thank you so much.

Dave

0 Kudos
Message 24 of 24
(1,186 Views)