获取label标签的文字:vb按钮问题高手指点下

来源:百度文库 编辑:高考问答 时间:2024/05/09 19:22:20
(复制下面的代码运行可以朗读但是按钮没有办法再按,只能关闭程序从新运行才可以。有没有办法让此程序不用从新运行就可以点按钮让其反复读音?《Command1.Enabled = true时就出问题》 )
Dim vText As New VTxtAuto.VTxtAuto

Private Sub Command1_Click()
Dim astr As String

Command1.Enabled = False
vText.Register vbNullString, "Speech"
'vtext.Register
astr = "This is a sample of Microsoft Speech Engine?"
vText.Speak astr, vtxtsp_NORMAL Or vtxtst_QUESTION
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set vText = Nothing
End Sub
Command1.Enabled = False
把这句话去掉
运行出错误
Command1.Enabled = true
也出错误

看来你使用的是微软的语音朗读库。

Command1.Enabled = False 这一句是不要的,
或者在后面加上
Command1.Enabled = true

Private Sub Command1_Click()
Dim astr As String

Command1.Enabled = False
vText.Register vbNullString, "Speech"
'vtext.Register
astr = "This is a sample of Microsoft Speech Engine?"
vText.Speak astr, vtxtsp_NORMAL Or vtxtst_QUESTION
Command1.Enabled = true

End Sub

不知道是不是微软语音引擎的不允许重入,好像我记得其实调用他的
speak 方法是直接返回的,没有这个问题。
我用的时候也没有用到vText.Register方法,不知道是不是这里的问题,
唉很久没用这个东西了,不是很清楚了。他详细有文档的,自己看看。

Dim vText As New VTxtAuto.VTxtAuto

好像这是一个旧的语音引擎了,在win2000下的,好像不能朗读中文。
到了winxp下好像不是这个吧,你到微软主页下载个新的吧。好像是什么
speech XXX SDK5.1 ,这个有文档很详细的。

Command1.Enabled = False
删掉这句话