Option Explicit
'- Chương trình có sử dụng thư viện Tổng hợp tiếng nói VnSpeech của Softex
'- Việc sử dụng thư viện VnSpeech này chỉ dùng cho mục đích học tập, nghiên cứu, không sử dụng cho các mục đích thương mại và phù hợp với yêu cầu của tác giả
Public strHelpFile As String 'Nếu bạn có tập tin trợ giúp Help.chm bạn có thể gán đường dẫn vào tham số này
' Khai báo hàm Việt Text to Speech trong thư viện Vnspeech.DLL
Public Declare Function VietTTS Lib "Vnspeech.DLL" (ByVal test As String) As Integer
'Khai báo hàm Stop giữa chừng khi VietTTS đang play
Public Declare Function VietTTSStop Lib "Vnspeech.DLL" () As Boolean
'___________________________________________________
'Hàm MessageBox dựa trên hàm MsgBox của Windows, thứ tự các tham số vẫn được dữ nguyên, chỉ bổ sung tham số dành cho đọc tiếng Việt và chức năng trợ giúp
Public Function MessageBox(Optional ByVal strPrompt As String, _
Optional ByVal vbButtons As VbMsgBoxStyle = vbMsgBoxHelpButton, _
Optional ByVal strTitle As String, _
Optional ByVal HelpFile As String, _
Optional ByVal varContext, _
Optional ByVal lngKey As Long, _
Optional ByVal blnMessageBox As Boolean = True, _
Optional ByVal blnVietTTS As Boolean = True, _
Optional ByVal strVietText As String) As VbMsgBoxResult
'blnVietTTS dùng để cho phép VNSpeech có speech hay không
'strVietText là chuỗi để speech
Select Case Err.Number
Case 9
strVietText = "Con trỏ vô định, dữ liệu đang được bảo vệ!"
strPrompt = strVietText & vbNewLine & "(" & Err.Description & ")"
Case 0
If strVietText = "" Then strVietText = strPrompt
Case Else:
strVietText = strPrompt
strPrompt = strVietText & vbNewLine & Err.Description
End Select
lngKey = Err.Number
If lngKey = 0 Then lngKey = CLng(vbButtons)
If HelpFile = "" Then HelpFile = IIf(strHelpFile = "", ThisWorkbook.Path & "\Help.chm", strHelpFile)
If blnVietTTS Then blnVietTTS = GetSetting("AccGroup", "OPTIONS", "Phatamcanhbao", True)
If IsMissing(varContext) Then varContext = 0
If Err.Number <> 0 Then
If strTitle = "" Then strTitle = "Lỗi hệ thống: " & Err.Number
strPrompt = "Không thực hiện được vì:" & vbNewLine & strPrompt
If strVietText = "" Then strVietText = "Không thực hiện được..."
If vbButtons = vbMsgBoxHelpButton Then
vbButtons = vbCritical + vbMsgBoxHelpButton
Else
vbButtons = vbButtons + vbMsgBoxHelpButton
End If
Else
If strTitle = "" Then strTitle = "Thông báo!"
If strVietText = "" Then strVietText = "Cẩn thận, kiểm tra và thử lại trước khi thực hiện!"
End If
Select Case vbButtons
Case vbMsgBoxHelpButton
vbButtons = vbInformation
Case vbYesNo, vbYesNoCancel, vbRetryCancel, vbAbortRetryIgnore
vbButtons = vbButtons + vbQuestion
Case vbOK
vbButtons = vbButtons + vbInformation
End Select
vbButtons = vbButtons + vbMsgBoxHelpButton
If blnVietTTS Then VietTTS (strVietText)
MessageBox = MsgBox(strPrompt, vbButtons, strTitle, HelpFile, varContext)
If blnVietTTS Then VietTTSStop
End Function