Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

如何让access发声朗读

时 间:2007-11-28 13:48:58
作 者:Fans   ID:85  城市:广州
摘 要:让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交流群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助