SICL: Error Handler Read Me
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'errhand.bas
'In this example, the error handler displays the error message
'in a Message Box and then terminates the program.
‘The following is a preview of the errhand.bas program:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'' """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
''  Copyright © 1999 - 2001 Keysight Technologies Inc.  All rights reserved.
''
'' You have a royalty-free right to use, modify, reproduce and distribute
'' the Sample Application Files (and/or any modified version) in any way
'' you find useful, provided that you agree that Keysight Technologies has no
'' warranty,  obligations or liability for any Sample Application Files.
''
'' Keysight Technologies provides programming examples for illustration only,
'' This sample program assumes that you are familiar with the programming
'' language being demonstrated and the tools used to create and debug
'' procedures. Keysight Technologies support engineers can help explain the
'' functionality of Keysight Technologies software components and associated
'' commands, but they will not modify these samples to provide added
'' functionality or construct procedures to meet your specific needs.
'' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
'' To develop SICL applications in Microsoft Visual Basic, you first need
'' to add the Visual Basic (VB) declaration file in your VB project as a
'' Module. This file contains the SICL function definitions and constant
'' declarations needed to make SICL calls from Visual Basic.
'' To add this module to your project in VB 6, from the menu, select
'' Project|Add Module, select the 'Existing' tab, and browse to the
'' directory containing the VB Declaration file, select sicl32.bas, and
'' click 'Open'.
''
'' The name and location of the VB declaration file depends on which
'' operating system you are using.  Assuming the Keysight IO Libraries
'' are installed in the 'standard' location:
''
''              C:\Program Files\Keysight\IO Libraries
''
'' the sicl32.bas file can be located in:
''
''   C:\Program Files\Keysight\IO Libraries\vb - Windows 95/98/Me/NT/2000
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'errhand.bas
'In this example, the error handler displays the error message
'in a Message Box and then terminates the program.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Main()
    Dim dvm As Integer
    Dim res As Double
    '  Install an error handler
    On Error GoTo ErrorHandler
    ' "hpib7" is the SICL Interface name as defined in:
    '     Start|Programs|Keysight IO Libraries|IO Config
    ' "22" is the instrument gpib address on the bus
    ' Change these to the SICL Name and gpib address for your instrument
    dvm = iopen("hpib7,22")
    ' Set timeout to 5 seconds
    Call itimeout(dvm, 5000)
    ' Take a measurement
    Call ivprintf(dvm, "MEAS:VOLT:DC?" + Chr$(10), 0&)
    ' Read the results
    Call ivscanf(dvm, "%lf", res)
    MsgBox "Result is " + Format(res)
    iclose (dvm)
    ' Tell SICL to cleanup for this task
    Call siclcleanup
    Exit Sub
ErrorHandler:
   '  Display the error message
      MsgBox "*** Error : " + Error, vbExclamation
   '  Tell SICL to cleanup for this task
   Call siclcleanup
End Sub