02-07-2018 01:07 PM
I currently use:
Try
myInstr.IO = IoMgr.Open("USB0::0x05E6::0x2636::4351628::INSTR")
Catch ex As Exception
MsgBox("could not connect", vbOKOnly, "error opening connection")
myerror = True
End Try
Solved! Go to Solution.
02-08-2018
09:01 AM
- last edited on
06-10-2025
10:26 AM
by
Content Cleaner
Have you looked into this example
02-08-2018 04:11 PM
Yes. Before trying any of the examples in VB.Net, the manual says I need to add a reference to visa32.dll. Visual Studio won't let me do this. BTW, I'm using a 64 bit machine.
02-09-2018 06:55 AM
Why are you unable to reference the visa32.dll, we would need more info about what specifically you are seeing to see what recommendations we can provide.
02-09-2018 12:01 PM
Thanks. Sure, here's what happens. See attached.
02-12-2018 04:33 PM
This seems to be an issue calling the library itself and most cases I've seen with this message seem to require calling the library with DLLimport, below are some examples and documentation for this.
https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx
https://docs.microsoft.com/en-us/dotnet/framework/interop/platform-invoke-examples
02-13-2018 11:12 AM
Hi,
In the project properties page set the target CPU to x86
Curt
02-14-2018 11:44 AM
I've heard about changing the target to x86. I've tried it and it doesn't work for me. Thanks, though.
02-14-2018 12:16 PM
I've checked out the pages mentioned and I should tell you that I find Microsoft's Developer website totally unfriendly to beginners. Their explanations are cryptic to me (at best).
I would very much appreciate an example, if possible. I have found that NI does provide some examples, but they are for VB6 and C#. I loved VB6 but it appears to be dying and I can't find it anymore, so I'm trying to learn VB.NET. Here's a header title for NI's C# example:
// Title : MainForm.cs
// Purpose : This application shows the user how to use ResourceManager to
// find all of the available resources on their system. In the example,
// they can select between several filters to narrow the list. Public
// property ResourceName contains the resource name selected in tvwResourceTree
//
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Ivi.Visa;
using NationalInstruments.Visa;
......................
It's kinda like VB but, of course, calls to VISA functions don't work. Any examples VB.NET?
02-14-2018 12:53 PM
Hi,
Set a reference to the NI Common and VisaNS libraries. Make sure the versions match.
Then try something like the code below. An you still need to go to the properties page and set the target to x86!
Good luck
Curt
Imports NationalInstruments.VisaNS
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim id As String
Dim resourcename As String
Dim usbsession As UsbSession
Try
' Add your resource string here
resourcename = "USB0::0x05E6::0x2601::4018686::INSTR"
usbsession = New UsbSession(resourcename)
usbsession.Write("*CLS")
usbsession.Write("*RST")
usbsession.Write("*IDN?")
id = usbsession.ReadString()
MessageBox.Show("ID = " + id)
Catch ex As Exception
End Try
End Sub
End Class