02-14-2018 12:54 PM
and you might want to remove the reference to IVI.Visa
02-14-2018 04:15 PM
Thanks, but the resource string
"USB0::0x05E6::0x2601::4018686::INSTR"
is precisely what I would like to retrieve. After retrieving the resource string, I can open communication with the device.
02-15-2018 06:01 AM
Sorry , I missed that.
Here's some code I wrote a while ago. It's in C# but you should be able to translate it to VB.
I don't have any hardware at my desk so I didn't test it, but I think it works.
Curt
private bool FindUSBResources() { HardwareInterfaceType intType; short intNum; try { string[] resources = ResourceManager.GetLocalManager().FindResources("?*"); Trace.WriteLine("FindUSB " + resources.Length); //string[] resources = ResourceManager.GetLocalManager().FindResources(m_resourcename ); if (resources.Length > 0) { foreach (string s in resources) { ResourceManager.GetLocalManager().ParseResource(s, out intType, out intNum); if (s.Contains(m_resourcename) == true) { m_sessiontype = 0; return true; } } } else { return false; } return false; } catch (VisaException vex) { Trace.WriteLine("Visa: " + vex.Message.ToString()); return false; } catch (Exception ex) { Trace.WriteLine(ex.Message.ToString()); return false; } }
02-15-2018 12:43 PM - edited 02-15-2018 12:45 PM
In the line: ResourceManager.GetLocalManager().FindResources("?*")
I get an error saying: GetLocalManager is not a member of ResourceManager
ResourceManager is OK as it is a member of Imports NationalInstruments.Visa
02-15-2018
02:08 PM
- last edited on
06-10-2025
10:27 AM
by
Content Cleaner
Hi
This code worked for me.
Here's the output. I don't have any instruments connected.
0 ASRL1::INSTR
1 ASRL10::INSTR
2 GPIB0::INTFC
GetLocalManager() is listed here...
http://zone.ni.com/reference/en-XX/help/370627F-01/mstudiowebhelp/html/1ab541cb/
Curt
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim intType As HardwareInterfaceType Dim intNum As Short Dim j As Integer Try Dim resources As String() resources = ResourceManager.GetLocalManager().FindResources("?*") For j = 0 To resources.Length - 1 Debug.WriteLine(j.ToString() + " " + resources(j)) Next Catch ex As Exception End Try End Sub
02-15-2018 03:42 PM
... ResourceManager.GetLocalManager... doesn't work for me. Are you using VisaNS.dll for reference? I've got : nationalinstruments.Visa and IVI.Visa referenced. I can't find VisaNS.
imports:
Imports NationalInstruments.Visa
Imports Ivi.Visa
02-15-2018 04:15 PM
Hey,
I have
Imports NationalInstruments.VisaNS
The Reference I have is Ver 13.0.35.190
The version of NI-VISA listed in MAX is 14.0.1
Curt
02-15-2018 04:59 PM
Here's what I have. I don't have NationalInstruments.VisaNS and I don't know how to get it.
02-16-2018 05:44 AM
Hi,
Look in the NI folder under C:\Program Files (x86). It should be in one of the Measurement Studio folders.
Mine is located at
C:\Program Files (x86)\National Instruments\MeasurementStudioVS2008\DotNET\Assemblies\Current\NationalInstruments.VisaNS.dll
If you can't find it, you might have to reinstall and select the option to install support for .NET
Curt
02-16-2018 11:50 AM
Well I guess that's the problem. I don't have Measurement Studio. Do I need to buy it?