Error, ReadyState, SnapshotPath Properties Example

The following example shows one way to use the Error, ReadyState, and SnapshotPath properties to load a snapshot file into a snapshot control. In this example, snpCtl is a variable representing a snapshot control on a form and strFilePath is the fully-qualified path to a snapshot file to be displayed.

Function LoadSnapshotFile(snpCtl As Object, strFilePath As String) As Boolean
    Const conSnpFinishedDownload As Integer = 4
    With snpCtl
        .SnapshotPath = strFilePath
        Do While .ReadyState < conSnpFinishedDownload
            DoEvents
        Loop
        If .Error = 0 Then
            LoadSnapshotFile = True
            Exit Function
        Else
            MsgBox "Error loading snapshot file", _
                vbOKOnly, "Snapshot Error = " & .Error
            LoadSnapShotFile = False
        End If
    End With
End Function