📄 nidaqmx.bas
字号:
Attribute VB_Name = "NIDAQmx"
Option Explicit
Public Enum DAQmxLineGrouping
DAQmx_Val_ChanPerLine = 0
DAQmx_Val_ChanForAllLines = 1
End Enum
Public Enum DAQmxValGroup
DAQmx_Val_GroupByChannel = 0
DAQmx_Val_GroupByScanNumber = 1
End Enum
Public Declare Function DAQmxCreateTask Lib "nicaiu.dll" (ByVal taskName As String, ByRef taskHandle As Long) As Long
Public Declare Function DAQmxCreateDOChan Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal lines As String, ByVal nameToAssignToLines As String, ByVal lineGrouping As DAQmxLineGrouping) As Long
Public Declare Function DAQmxStartTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Public Declare Function DAQmxWriteDigitalLines Lib "nicaiu.dll" (ByVal taskHandle As Long, ByVal numSampsPerChan As Long, ByVal autoStart As Long, ByVal timeout As Double, ByVal dataLayout As DAQmxValGroup, ByRef writeArray As Byte, ByRef sampsPerChanWritten As Long, ByVal reserved As Long) As Long
Public Declare Function DAQmxStopTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Public Declare Function DAQmxClearTask Lib "nicaiu.dll" (ByVal taskHandle As Long) As Long
Public Declare Function DAQmxGetErrorString Lib "nicaiu.dll" (ByVal errorCode As Long, ByVal errorString As String, ByVal bufferSize As Long) As Long
Public Sub DAQmxErrChk(errorCode As Long)
'
' Utility function to display a MsgBox showing the DAQmx error code
' and message, then ends the program (if an error occured).
'
Dim errorString As String
Dim bufferSize As Long
If (errorCode < 0) Then
' Find out the error message length.
bufferSize = DAQmxGetErrorString(errorCode, 0, 0)
' Allocate enough space in the string.
errorString = String(bufferSize, Chr$(0))
' Get the actual error message.
DAQmxGetErrorString errorCode, errorString, bufferSize
' Trim it to the actual length, and display the message
errorString = Left(errorString, InStr(errorString, Chr$(0)) - 1)
MsgBox "DAQmx error code = " & errorCode & vbNewLine & "Error message = " & errorString
End
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -