I am having a problem and that is I have buttons to read text to speech like play pause and stop

I have created 4 buttons Play,Pause,Stop,Resume
but now I dont want the Resume button, instead when I click on the pause button it should pause the speech and later when I click the same button again I need the speach to be resumed
this is what I wrote
I know this is chilish then also I am not getting it plz help ASAP !

Public SAPI = CreateObject("SAPI.spvoice")

Private Sub startSpeaking_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startSpeaking.Click
    SAPI.speak(RichTextBox1.Text, 3)
    findHighlight(TextBox1.Text)
End Sub

Private Sub pauseSpeech_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pauseSpeech.Click
    SAPI.Pause()
End Sub

Private Sub stopSpeech_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stopSpeech.Click
    SAPI.Speak(vbNullString, 2)
    'SAPI = Nothing
End Sub

Private Sub resumeSpeech_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles resumeSpeech.Click
    SAPI.Resume()
End Sub

Recommended Answers

All 4 Replies

Declare a boolean variable at the top of the class.

public Paused as Boolean = false
'When you fire your click event do this;
If Paused = false Then
    'Pause code here
    Paused = true
ElseIf Paused = True Then
    'Unpause code here.
    Paused = False
End If

Thanks a lot for helping me !

Thanks a lot for helping me !

Np, friend. Don't forget to marked the thread as solved. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.