你好,我想得到一些幫助..因爲我的程序「BINGO調用者」SAPI/SpVoice總是在我的文本框中顯示值之前先說話。還有其他問題是在講SAPI時,所有的按鈕和命令都不起作用,當SAPI講完並且他們說話的號碼在講話後顯示在texbox中時,它們就會變得正常。請幫助我..我希望我的程序顯示數字,而SAPI在我的文本框中說出數值。請幫幫我。這是我在顯示在文本框中的數字和字母的代碼,這是SAPI代碼VB.NEt SpVoice/SAPI總是先行動
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
nos = randomarray(index)
index = index + 1
If nos <= 15 And nos >= 1 Then
col = "B"
ElseIf nos <= 30 And nos >= 16 Then
col = "I"
ElseIf nos <= 45 And nos >= 31 Then
col = "N"
ElseIf nos <= 60 And nos >= 46 Then
col = "G"
ElseIf nos <= 75 And nos >= 61 Then
col = "O"
End If
lbl_no.Text = nos
lbl_let.Text = col
sVar = Mid(nos, 1, 1)
sVar2 = Mid(nos, 2)
CType(Me.Controls("lbl_" & nos.ToString), Label).BackColor = Color.Yellow
If index = randomarray.Count Then
Timer1.Stop()
btn_pause.Enabled = False
btn_clear.Show()
btn_exit.Hide()
End If
voice()
txt_count.Text = index - 1
End Sub
這是對SAPI代碼
Sub voice()
Dim VObj As Object
VObj = CreateObject("SAPI.SpVoice")
With VObj
.Volume = 100
.Rate = -2
.Speak(col & " " & nos)
.Speak(col & " " & sVar & " " & sVar2)
End With
End Sub
This is my Screenshot of my program
嘗試調用'語音()'方法調用,我也動'txt_count.Text =索引之前增加一個'Application.DoEvents()' - '的聲音()'方法調用之前1' –
問題是因爲說話庫正在使用主線程,從而凍結所有內容直到完成。理想的解決方案是讓它在不同的線程上運行。嘗試搜索'.net Tasks' :)'Tasks.Run(AddressOf Voice)' –
可以請你給我舉個例子...謝謝...我對此沒有任何想法:( –