Specifications

Chapter 16 191
ESA/PSA Programming Examples
Using Visual Basic® 6 to Capture a Screen Image
ESA/PSA Programming Examples
Delete the tempory file on the flash named C:PICTURE.GIF
status = viVPrintf(vi, ":MMEM:DEL C:PICTURE.GIF" + Chr$(10), 0)
If (status < 0) Then GoTo VisaErrorHandler
Close the vi session and the resource manager session
Call viClose(vi)
Call viClose(defrm)
Store the results in a text file
fnum = FreeFile() Get the next free file number
Open "picture.gif" For Binary As #fnum
isOpen = True
headerlength = 2 + (Chr$(ResultsArray(1)))
For x = headerlength To length - 2
Put #fnum, , ResultsArray(x)
Next x
Intentionally flow into Error Handler to close file
Error_Handler:
Raise the error (if any), but first close the file
If isOpen Then Close #fnum
If Err Then Err.Raise Err.Number, , Err.Description
Exit Sub
VisaErrorHandler:
Dim strVisaErr As String * 200
Call viStatusDesc(defrm, status, strVisaErr)
MsgBox "*** Error : " & strVisaErr, vbExclamation, "VISA Error Message"
Exit Sub
End Sub