📄 vbib-32.bas
字号:
Attribute VB_Name = "VBIB32"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 32-bit Visual Basic Language Interface
' Version 1.7
' Copyright 1998 National Instruments Corporation.
' All Rights Reserved.
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This module contains the subroutine declarations,
' function declarations and constants required to use
' the National Instruments GPIB Dynamic Link Library
' (DLL) for controlling IEEE-488 instrumentation. This
' file must be 'added' to your Visual Basic project
' (by choosing Add File from the File menu or pressing
' CTRL+F12) so that you can access the NI-488.2
' subroutines and functions.
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' NI-488.2 DLL entry function declarations
Declare Function ibask32 Lib "Gpib-32.dll" Alias "ibask" (ByVal ud As Long, ByVal opt As Long, value As Long) As Long
Declare Function ibbna32 Lib "Gpib-32.dll" Alias "ibbnaA" (ByVal ud As Long, sstr As Any) As Long
Declare Function ibcac32 Lib "Gpib-32.dll" Alias "ibcac" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibclr32 Lib "Gpib-32.dll" Alias "ibclr" (ByVal ud As Long) As Long
Declare Function ibcmd32 Lib "Gpib-32.dll" Alias "ibcmd" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibcmda32 Lib "Gpib-32.dll" Alias "ibcmda" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibconfig32 Lib "Gpib-32.dll" Alias "ibconfig" (ByVal ud As Long, ByVal opt As Long, ByVal v As Long) As Long
Declare Function ibdev32 Lib "Gpib-32.dll" Alias "ibdev" (ByVal bdid As Long, ByVal pad As Long, ByVal sad As Long, ByVal tmo As Long, ByVal eot As Long, ByVal eos As Long) As Long
Declare Function ibdma32 Lib "Gpib-32.dll" Alias "ibdma" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibeos32 Lib "Gpib-32.dll" Alias "ibeos" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibeot32 Lib "Gpib-32.dll" Alias "ibeot" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibfind32 Lib "Gpib-32.dll" Alias "ibfindA" (sstr As Any) As Long
Declare Function ibgts32 Lib "Gpib-32.dll" Alias "ibgts" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibist32 Lib "Gpib-32.dll" Alias "ibist" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function iblines32 Lib "Gpib-32.dll" Alias "iblines" (ByVal ud As Long, v As Long) As Long
Declare Function ibln32 Lib "Gpib-32.dll" Alias "ibln" (ByVal ud As Long, ByVal pad As Long, ByVal sad As Long, ln As Long) As Long
Declare Function ibloc32 Lib "Gpib-32.dll" Alias "ibloc" (ByVal ud As Long) As Long
Declare Function iblock32 Lib "Gpib-32.dll" Alias "iblock" (ByVal ud As Long) As Long
Declare Function ibonl32 Lib "Gpib-32.dll" Alias "ibonl" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibpad32 Lib "Gpib-32.dll" Alias "ibpad" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibpct32 Lib "Gpib-32.dll" Alias "ibpct" (ByVal ud As Long) As Long
Declare Function ibppc32 Lib "Gpib-32.dll" Alias "ibppc" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibrd32 Lib "Gpib-32.dll" Alias "ibrd" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibrda32 Lib "Gpib-32.dll" Alias "ibrda" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibrdf32 Lib "Gpib-32.dll" Alias "ibrdfA" (ByVal ud As Long, sstr As Any) As Long
Declare Function ibrpp32 Lib "Gpib-32.dll" Alias "ibrpp" (ByVal ud As Long, sstr As Any) As Long
Declare Function ibrsc32 Lib "Gpib-32.dll" Alias "ibrsc" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibrsp32 Lib "Gpib-32.dll" Alias "ibrsp" (ByVal ud As Long, sstr As Any) As Long
Declare Function ibrsv32 Lib "Gpib-32.dll" Alias "ibrsv" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibsad32 Lib "Gpib-32.dll" Alias "ibsad" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibsic32 Lib "Gpib-32.dll" Alias "ibsic" (ByVal ud As Long) As Long
Declare Function ibsre32 Lib "Gpib-32.dll" Alias "ibsre" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibstop32 Lib "Gpib-32.dll" Alias "ibstop" (ByVal ud As Long) As Long
Declare Function ibtmo32 Lib "Gpib-32.dll" Alias "ibtmo" (ByVal ud As Long, ByVal v As Long) As Long
Declare Function ibtrg32 Lib "Gpib-32.dll" Alias "ibtrg" (ByVal ud As Long) As Long
Declare Function ibunlock32 Lib "Gpib-32.dll" Alias "ibunlock" (ByVal ud As Long) As Long
Declare Function ibwait32 Lib "Gpib-32.dll" Alias "ibwait" (ByVal ud As Long, ByVal mask As Long) As Long
Declare Function ibwrt32 Lib "Gpib-32.dll" Alias "ibwrt" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibwrta32 Lib "Gpib-32.dll" Alias "ibwrta" (ByVal ud As Long, sstr As Any, ByVal cnt As Long) As Long
Declare Function ibwrtf32 Lib "Gpib-32.dll" Alias "ibwrtfA" (ByVal ud As Long, sstr As Any) As Long
Declare Sub AllSpoll32 Lib "Gpib-32.dll" Alias "AllSpoll" (ByVal ud As Long, arg1 As Any, arg2 As Any)
Declare Sub DevClear32 Lib "Gpib-32.dll" Alias "DevClear" (ByVal ud As Long, ByVal v As Long)
Declare Sub DevClearList32 Lib "Gpib-32.dll" Alias "DevClearList" (ByVal ud As Long, arg1 As Any)
Declare Sub EnableLocal32 Lib "Gpib-32.dll" Alias "EnableLocal" (ByVal ud As Long, arg1 As Any)
Declare Sub EnableRemote32 Lib "Gpib-32.dll" Alias "EnableRemote" (ByVal ud As Long, arg1 As Any)
Declare Sub FindLstn32 Lib "Gpib-32.dll" Alias "FindLstn" (ByVal ud As Long, arg1 As Any, arg2 As Any, ByVal limit As Long)
Declare Sub FindRQS32 Lib "Gpib-32.dll" Alias "FindRQS" (ByVal ud As Long, arg1 As Any, result As Long)
Declare Sub PassControl32 Lib "Gpib-32.dll" Alias "PassControl" (ByVal ud As Long, ByVal addr As Long)
Declare Sub PPoll32 Lib "Gpib-32.dll" Alias "PPoll" (ByVal ud As Long, result As Long)
Declare Sub PPollConfig32 Lib "Gpib-32.dll" Alias "PPollConfig" (ByVal ud As Long, ByVal addr As Long, ByVal line As Long, ByVal sense As Long)
Declare Sub PPollUnconfig32 Lib "Gpib-32.dll" Alias "PPollUnconfig" (ByVal ud As Long, arg1 As Any)
Declare Sub RcvRespMsg32 Lib "Gpib-32.dll" Alias "RcvRespMsg" (ByVal ud As Long, arg1 As Any, ByVal cnt As Long, ByVal term As Long)
Declare Sub ReadStatusByte32 Lib "Gpib-32.dll" Alias "ReadStatusByte" (ByVal ud As Long, ByVal addr As Long, result As Long)
Declare Sub Receive32 Lib "Gpib-32.dll" Alias "Receive" (ByVal ud As Long, ByVal addr As Long, arg1 As Any, ByVal cnt As Long, ByVal term As Long)
Declare Sub ReceiveSetup32 Lib "Gpib-32.dll" Alias "ReceiveSetup" (ByVal ud As Long, ByVal addr As Long)
Declare Sub ResetSys32 Lib "Gpib-32.dll" Alias "ResetSys" (ByVal ud As Long, arg1 As Any)
Declare Sub Send32 Lib "Gpib-32.dll" Alias "Send" (ByVal ud As Long, ByVal addr As Long, sstr As Any, ByVal cnt As Long, ByVal term As Long)
Declare Sub SendCmds32 Lib "Gpib-32.dll" Alias "SendCmds" (ByVal ud As Long, sstr As Any, ByVal cnt As Long)
Declare Sub SendDataBytes32 Lib "Gpib-32.dll" Alias "SendDataBytes" (ByVal ud As Long, sstr As Any, ByVal cnt As Long, ByVal term As Long)
Declare Sub SendIFC32 Lib "Gpib-32.dll" Alias "SendIFC" (ByVal ud As Long)
Declare Sub SendList32 Lib "Gpib-32.dll" Alias "SendList" (ByVal ud As Long, arg1 As Any, arg2 As Any, ByVal cnt As Long, ByVal term As Long)
Declare Sub SendLLO32 Lib "Gpib-32.dll" Alias "SendLLO" (ByVal ud As Long)
Declare Sub SendSetup32 Lib "Gpib-32.dll" Alias "SendSetup" (ByVal ud As Long, arg1 As Any)
Declare Sub SetRWLS32 Lib "Gpib-32.dll" Alias "SetRWLS" (ByVal ud As Long, arg1 As Any)
Declare Sub TestSys32 Lib "Gpib-32.dll" Alias "TestSys" (ByVal ud As Long, arg1 As Any, arg2 As Any)
Declare Sub Trigger32 Lib "Gpib-32.dll" Alias "Trigger" (ByVal ud As Long, ByVal addr As Long)
Declare Sub TriggerList32 Lib "Gpib-32.dll" Alias "TriggerList" (ByVal ud As Long, arg1 As Any)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DLL entry function declarations needed for GPIB global variables
Declare Function RegisterGpibGlobalsForThread Lib "Gpib-32.dll" (Longibsta As Long, Longiberr As Long, Longibcnt As Long, ibcntl As Long) As Long
Declare Function UnregisterGpibGlobalsForThread Lib "Gpib-32.dll" () As Long
Declare Function ThreadIbsta32 Lib "Gpib-32.dll" Alias "ThreadIbsta" () As Long
Declare Function ThreadIbcnt32 Lib "Gpib-32.dll" Alias "ThreadIbcnt" () As Long
Declare Function ThreadIbcntl32 Lib "Gpib-32.dll" Alias "ThreadIbcntl" () As Long
Declare Function ThreadIberr32 Lib "Gpib-32.dll" Alias "ThreadIberr" () As Long
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DLL entry function declarations needed for GPIBnotify OLE control
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DLL entry function declarations needed for GPIB-ENET functions
Declare Function iblockx32 Lib "Gpib-32.dll" Alias "iblockxA" (ByVal ud As Long, ByVal LockWaitTime As Long, arg1 As Any) As Long
Declare Function ibunlockx32 Lib "Gpib-32.dll" Alias "ibunlockx" (ByVal ud As Long) As Long
Sub AllSpoll(ByVal ud As Integer, addrs() As Integer, results() As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call AllSpoll32(ud, addrs(0), results(0))
Call copy_ibvars
End Sub
Sub copy_ibvars()
ibsta = ConvertLongToInt(Longibsta)
iberr = CInt(Longiberr)
ibcnt = ConvertLongToInt(ibcntl)
End Sub
Sub DevClear(ByVal ud As Integer, ByVal addr As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call DevClear32(ud, addr)
Call copy_ibvars
End Sub
Sub DevClearList(ByVal ud As Integer, addrs() As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call DevClearList32(ud, addrs(0))
Call copy_ibvars
End Sub
Sub EnableLocal(ByVal ud As Integer, addrs() As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call EnableLocal32(ud, addrs(0))
Call copy_ibvars
End Sub
Sub EnableRemote(ByVal ud As Integer, addrs() As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call EnableRemote32(ud, addrs(0))
Call copy_ibvars
End Sub
Sub FindLstn(ByVal ud As Integer, addrs() As Integer, results() As Integer, ByVal limit As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call FindLstn32(ud, addrs(0), results(0), limit)
Call copy_ibvars
End Sub
Sub FindRQS(ByVal ud As Integer, addrs() As Integer, result As Integer)
Dim tmpresult As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call FindRQS32(ud, addrs(0), tmpresult)
result = ConvertLongToInt(tmpresult)
Call copy_ibvars
End Sub
Sub ibask(ByVal ud As Integer, ByVal opt As Integer, rval As Integer)
Dim tmprval As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibask32(ud, opt, tmprval)
rval = ConvertLongToInt(tmprval)
Call copy_ibvars
End Sub
Sub ibbna(ByVal ud As Integer, ByVal udname As String)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibbna32(ud, ByVal udname)
Call copy_ibvars
End Sub
Sub ibcac(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibcac32(ud, v)
Call copy_ibvars
End Sub
Sub ibclr(ByVal ud As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibclr32(ud)
Call copy_ibvars
End Sub
Sub ibcmd(ByVal ud As Integer, ByVal buf As String)
Dim cnt As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
cnt = CLng(Len(buf))
' Call the 32-bit DLL.
Call ibcmd32(ud, ByVal buf, cnt)
Call copy_ibvars
End Sub
Sub ibcmda(ByVal ud As Integer, ByVal buf As String)
Dim cnt As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
cnt = CLng(Len(buf))
' Call the 32-bit DLL.
Call ibcmd32(ud, ByVal buf, cnt)
' When Visual Basic remapping buffer problem solved, then use:
' call ibcmda32(ud, ByVal buf, cnt)
Call copy_ibvars
End Sub
Sub ibconfig(ByVal bdid As Integer, ByVal opt As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibconfig32(bdid, opt, v)
Call copy_ibvars
End Sub
Sub ibdev(ByVal bdid As Integer, ByVal pad As Integer, ByVal sad As Integer, ByVal tmo As Integer, ByVal eot As Integer, ByVal eos As Integer, ud As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
ud = ConvertLongToInt(ibdev32(bdid, pad, sad, tmo, eot, eos))
Call copy_ibvars
End Sub
Sub ibdma(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibdma32(ud, v)
Call copy_ibvars
End Sub
Sub ibeos(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibeos32(ud, v)
Call copy_ibvars
End Sub
Sub ibeot(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibeot32(ud, v)
Call copy_ibvars
End Sub
Sub ibfind(ByVal udname As String, ud As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
ud = ConvertLongToInt(ibfind32(ByVal udname))
Call copy_ibvars
End Sub
Sub ibgts(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibgts32(ud, v)
Call copy_ibvars
End Sub
Sub ibist(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibist32(ud, v)
Call copy_ibvars
End Sub
Sub iblines(ByVal ud As Integer, lines As Integer)
Dim tmplines As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call iblines32(ud, tmplines)
lines = ConvertLongToInt(tmplines)
Call copy_ibvars
End Sub
Sub ibln(ByVal ud As Integer, ByVal pad As Integer, ByVal sad As Integer, ln As Integer)
Dim tmpln As Long
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibln32(ud, pad, sad, tmpln)
ln = ConvertLongToInt(tmpln)
Call copy_ibvars
End Sub
Sub ibloc(ByVal ud As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibloc32(ud)
Call copy_ibvars
End Sub
Sub ibonl(ByVal ud As Integer, ByVal v As Integer)
' Check to see if GPIB Global variables are registered
If (GPIBglobalsRegistered = 0) Then
Call RegisterGPIBGlobals
End If
' Call the 32-bit DLL.
Call ibonl32(ud, v)
Call copy_ibvars
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -