?? s2l3.bas
字號(hào):
Option Explicit
'**********************************************************************
'* S2L3.bas - (Section 2, Lesson 3) RECEIVING ENTIRE MESSAGES USING
'* SAFEARRAYS
'* This is the RTDX Host Client for Section 2, Lesson 3
'*
'* This example receives integer values 1-10 from the target
'**********************************************************************
Const Success = &H0 ' Method call is valid
Const Failure = &H80004005 ' Method call failed
Const ENoDataAvailable = &H8003001E ' No data was available.
' However, more data may be
' available in the future.
Const EEndOfLogFile = &H80030002 ' No data was available
' The end of the log file has
' been reached.
Sub main()
Dim rtdx As Object
'******************************************************************
' Insert code from Step #3 here - to declare a variable of type
' Variant. This variable contains
' a pointer to a SAFEARRAY
'******************************************************************
Dim vardata As Variant
Dim status As Long
Dim i As Long
On Error GoTo Error_Handler
' Create an instance of the RTDX COM object
Set rtdx = CreateObject("RTDX")
' Open channel ochan for reading
status = rtdx.Open("ochan", "R")
If status <> Success Then
Debug.Print "Opening of channel ochan failed"
Goto Error_Handler
End If
Do
'**************************************************************
' Insert code from Step #4 here - to read a message (16-bit
' integer array) from the
' target
'**************************************************************
status = rtdx.ReadSAI2(vardata)
Select Case (status)
Case Success
'******************************************************
' Insert code from Step #5 here - to print each element
' in the array
'******************************************************
For i = LBound(vardata) To UBound(vardata)
Debug.Print vardata(i)
Next i
Case ENoDataAvailable
Debug.Print "No data is currently available"
Case EEndOfLogFile
Debug.Print "End of log file has been detected"
Case Failure
Debug.Print "ReadSAI2 returned failure"
Exit Do
Case Else
Debug.Print "Unknown return code"
Exit Do
End Select
Loop Until status = EEndOfLogFile
' Close the channel
status = rtdx.Close()
' Release the reference to the RTDX COM object
Set rtdx = Nothing
Exit Sub
Error_Handler:
Debug.Print "Error in COM method call"
Set rtdx = Nothing
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -