KEPCO KLP Series Developers Guide, Rev 3 User Manual
Page 39

KLP-DEV 041213
3-17
FIGURE 3-4. EXAMPLE OF USING A LIST, WRITTEN IN VISUAL BASIC (SHEET 1 OF 2)
FIGURE 3-4. EXAMPLE OF USING A LIST, WRITTEN IN VISUAL BASIC (SHEET 2 OF 2)
'/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'This program executes a 6 point current and voltage list. 
' It also specifies 3 different dwell times.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Option Explicit
Public driver As KepcoDCPwr
Public outputPtr As IKepcoKLPOutput
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdStart_Click()
 
 Set driver = New KepcoDCPwr
 
 On Error GoTo errorHandler
 
 ' initialize the driver
 
 driver.Initialize "GPIB0::6::INSTR", _
 False, _
 True, _
 "Cache=true,InterchangeCheck=false,QueryInstrStatus=true,Simulate=false"
 
 Dim result As Boolean
 result = driver.Initialized
 
 
 ' get references to the needed interfaces
 Set outputPtr = driver.Outputs.Item(driver.Outputs)
 Set listPtr =driver.list
 Delay (100)
 
 
 ReadInstrumentError driver
 
 driver.Close
 
 Exit Sub
errorHandler:
 MsgBox Err.Description
 driver.Close
 Exit Sub
End Sub
Private Sub ReadInstrumentError(agDrvr As IIviDriver)
 ' Read instrument error queue until its empty.
 Dim errCode As Long
 errCode = 999
 Dim errMsg As String
 
 StatusTextBox.Text = StatusTextBox.Text & vbCrLf
 While errCode <> 0
 agDrvr.Utility.ErrorQuery errCode, errMsg
 StatusTextBox.Text = StatusTextBox.Text & "ErrorQuery: " & errCode & ", " & errMsg & vbCrLf
 Wend
End Sub
' Wait the specified number of seconds
Private Sub Delay(DelayTime As Single)
 Dim Finish As Single
 Finish = Timer() + DelayTime
 Do
 Loop Until Finish <= Timer()
End Sub
