Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use viOpenDefaultRM() to open default resource manager via visual basic

hi all ,

my OS is windows 7 64 bit , and i want to control Tektronix oscilloscope via visual basic 6.

I installed NI-visa 17 driver and in installed path "....\IVI Foundation\VISA\WinNT\Include" i found visa32.bas . 

Then two questions :

1. what should i  input when i call function ViOpenDefaultRM(sesn&)    ?

    in NI-visa help i see this parameters is unique logical identifier to a default resource manager        session and direction is out . but how should I know this session and its value ?

     and the direction  --out is mean this parameters is transfered by address , right ?

 

 

2. in NI-VISA help  write if i want to use data type ViSession , ViStatus and so on ,l need to         reference visa32.dll file in system32 content. but when i reference this file , i was informed that :

bad reference. Could not load file or assembly "file :////C:\windows\System32\visa32.dll" or one of its dependencies. The module was expected to contain an assembly manifest. 

 

so do i really need to reference this visa32.dll ?

if so , why i can not reference this file successfully ?

and when i change language to vb.net , also can not reference this file

Option Explicit
'#Uses "C:\Program Files (x86)\IVI Foundation\VISA\WinNT\Include\visa32.bas"
'#Language "WWB.NET"
Sub Main
  '@TODO: enter code here

Const MAX_CNT = 200
Dim state As Long
Dim dfltRM As Long
Dim sesn As Long
Dim retCount As Long
Dim buffer As String
Rem Begin by initializing the system
state = viOpenDefaultRM(0)
If (state < VI_SUCCESS) Then
Rem Error initializing VISA...exiting
Exit Sub

End If

.

 

 

 

0 Kudos
Message 1 of 3
(4,598 Views)

If you installed NI-VISA after you installed VB.NET, it should include example programs.

Take a look at those.

 

 

0 Kudos
Message 2 of 3
(4,554 Views)

visa32.dll  is a Windows shared library, it is not a NET assembly (even if the file extension is the same) so you cannot reference it directly in a NET project.

For VB.NET you have the following options:

- use VISA-NET interface assembly provided by NI: https://www.ni.com/en/support/documentation/supplemental/15/national-instruments-visa--net-library.h...

- use my library : https://www.codeproject.com/Articles/1166996/Multithreaded-communication-for-GPIB-Visa-Serial-i

- import the functions you need from visa32.dll, you can look at the code in VisaDevice.vb in my library to see how to do it

 

0 Kudos
Message 3 of 3
(4,514 Views)