246
Chapter 6 Application Programs
Example Programs for Excel 7.0
Sub OpenPort()
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ Be sure that the GPIB address has been set in the ’VISAaddr’ variable
’ before calling this routine.
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ Open the VISA session
errorStatus =
viOpenDefaultRM(videfaultRM)
’ Open communications to the instrument
errorStatus =
viOpen(videfaultRM, "GPIB0::" & VISAaddr & "::INSTR", 0, 2500, vi)
’ If an error occurs, give a message
If errorStatus < VI_SUCCESS Then
Range("A2").Select
Cells(1, 1) = "Unable to Open Port"
End If
End Sub
Sub ClosePort()
errorStatus =
viClose(vi)
’ Close the session
errorStatus =
viClose(videfaultRM)
End Sub
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
’ This subroutine is used to create delays. The input is in seconds and
’ fractional seconds are allowed.
’""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Sub delay(delay_time As Single)
Dim Finish As Single
Finish = Timer + delay_time
Do
Loop Until Finish <= Timer
End Sub
34970A Refresh UG.book Page 246 Wednesday, February 17, 2010 12:34 PM
Summary of Contents for 34970A
Page 16: ...16 34970A Refresh UG book Page 16 Wednesday February 17 2010 12 34 PM ...
Page 20: ...34970A Refresh UG book Page 20 Wednesday February 17 2010 12 34 PM ...
Page 21: ...1 1 Quick Start 34970A Refresh UG book Page 21 Wednesday February 17 2010 12 34 PM ...
Page 39: ...2 2 Front Panel Overview 34970A Refresh UG book Page 39 Wednesday February 17 2010 12 34 PM ...
Page 59: ...3 3 System Overview 34970A Refresh UG book Page 59 Wednesday February 17 2010 12 34 PM ...
Page 87: ...4 4 Features and Functions 34970A Refresh UG book Page 87 Wednesday February 17 2010 12 34 PM ...
Page 217: ...5 5 Error Messages 34970A Refresh UG book Page 217 Wednesday February 17 2010 12 34 PM ...
Page 241: ...6 6 Application Programs 34970A Refresh UG book Page 241 Wednesday February 17 2010 12 34 PM ...
Page 254: ...254 34970A Refresh UG book Page 254 Wednesday February 17 2010 12 34 PM ...
Page 255: ...7 7 Tutorial 34970A Refresh UG book Page 255 Wednesday February 17 2010 12 34 PM ...
Page 324: ...324 34970A Refresh UG book Page 324 Wednesday February 17 2010 12 34 PM ...