A-4 Visual Basic Appendix A — Examples
A-10 PN: 10580-00322 Rev. F S331L PM
A-4 Visual Basic
This function can be called in a Visual Basic program. It demonstrates
connection and setting parameters in the instrument while using Ethernet
Socket protocol.
Public Sub CommunicationWithTCPIPSocket()
Const MAX_CNT = 200
Dim stat As Variant
Dim dfltRM As Variant
Dim sesn As Variant
Dim retCount As Long
Dim Buffer As String * MAX_CNT
Dim Response As String * VI_FIND_BUFLEN
Dim sInputString As String
Dim ipAddress As String
Dim Port As String
Rem Begin by initializing the system
stat = viOpenDefaultRM(dfltRM)
If (stat < VI_SUCCESS) Then
Rem Error initializing VISA...exiting
Exit Sub
End If
Rem Open communication with Ethernet Socket Protocol
Rem before open an new Ethernet session make sure session was closed
Rem NOTE: For simplicity, we will not show error checking
'address and port
'this sample address
ipAddress = "172.26.202.117"
'For S331L port will be 9001
Port = "9001"