Share via


ISpeechVoiceStatus LastHResult Property (SAPI 5.3)

Microsoft Speech API 5.3

Interface: ISpeechVoiceStatus

LastHResult Property

The LastHResult property retrieves the HResult, or internal status code, from the last Speak or SpeakStream operation performed by the SpVoice object.

Syntax

Set: (This property is read-only)
Get: Long = ISpeechVoiceStatus.LastHResult

Parts

  • ISpeechVoiceStatus
    The owning object.
  • Long
    Set: (This property is read-only)
    Get: A Long variable returning the HResult.

Example

The following Visual Basic form code demonstrates the use of the LastHResult property of an ISpeechVoiceStatus object. To run this code, create a form with the following controls:

  • A command button called Command1
  • A text box called Text1

Paste this code into the Declarations section of the form.

The Form_Load procedure creates a voice object. The Command1_Click procedure speaks a text stream asynchronously. The LastHResult property value is displayed in the text box. A value of 0 indicates completion with no error.

  
Option Explicit

Dim V As SpeechLib.SpVoice

Private Sub Command1_Click()
    On Error GoTo EH

    V.Speak "This is a text stream", SVSFlagsAsync

    'wait for maximum 10 seconds to finish speaking
    V.WaitUntilDone 10000

    Text1.Text = Format(V.Status.LastHResult)

EH:
    If Err.Number Then ShowErrMsg
End Sub

Private Sub Form_Load()

    Set V = New SpVoice

End Sub

Private Sub ShowErrMsg()

    ' Declare identifiers:
    Dim T As String

    T = "Desc: " & Err.Description & vbNewLine
    T = T & "Err #: " & Err.Number
    MsgBox T, vbExclamation, "Run-Time Error"
    End

End Sub