时 间:2007-11-28 13:48:58
作 者:摘 要:让ACCESS发出声来.
正 文:
代码出自Fans之手
首先要引用:Microsoft Speech Object Library
代码如下:
Function MySpeak(strSpeak As String, _
Optional intRate As Integer = 0, _
Optional intVolume As Integer = 50, _
Optional intVoiceID As Integer = 0) As Boolean
On Error GoTo Err_MySpeak
Dim oVoise As New SpeechLib.SpVoice
Dim intTotalSpeech As Integer
intTotalSpeech = oVoise.GetVoices.Count '获取朗读者的数量
If intTotalSpeech = 0 Then Exit Function
'设置朗读者
If intVoiceID > intTotalSpeech - 1 Then intVoiceID = 0
Set oVoise.Voice = oVoise.GetVoices.Item(intVoiceID)
'设置朗读速度
If intRate > 10 Then intRate = 10
If intRate < -10 Then intRate = -10
oVoise.Rate = intRate
'设置朗读音量
If intVolume > 100 Then intVolume = 100
If intVolume < 0 Then intVolume = 0
oVoise.Volume = intVolume
oVoise.Speak strSpeak
MySpeak = True
Exit_MySpeak:
Exit Function
Err_MySpeak:
MySpeak = False
MsgBox Err.Description, 64, "提示"
Resume Exit_MySpeak
End Function
Function TestSpeak()
Dim str As String
str = "欢迎进入奇妙世界"
Call MySpeak(str, 0, 100, 0)
End Function
Access软件网QQ交流群(群号:39785885)
Access源码网店