Function ReadOut(intX As Integer, intY As Integer)
Dim i As Integer
i = Len(CStr(intX))
If intX > 1000 Then
Exit Function
Else
Call PlaySound(MyPath & "invite.wav")
If intX >= 100 Then
Call PlaySound(MyPath & left(intX, 1) & ".wav")
Call PlaySound(MyPath & "roi.wav")
End If
intX = right(intX, 2)
If intX >= 30 Then
Call PlaySound(MyPath & left(intX, 1) & ".wav")
End If
If intX >= 20 And intX < 30 Then
Call PlaySound(MyPath & "yee.wav")
End If
If intX >= 10 Then
Call PlaySound(MyPath & "sib.wav")
End If
intX = right(intX, 1)
If intX > 0 Then
If intX = 1 Then
If i = 1 Then
Call PlaySound(MyPath & "1.wav")
Else
Call PlaySound(MyPath & "ed.wav")
End If
Else
Call PlaySound(MyPath & intX & ".wav")
End If
End If
Call PlaySound(MyPath & "at.wav")
Call PlaySound(MyPath & intY & ".wav")
End If
End Function
Function MyPath() As String
Dim strPath As String
strPath = CurrentDb.Name
MyPath = left(strPath, Len(strPath) - Len(Dir(strPath)))
End Function
โค๊ตใน form หลักค่ะ
Option Compare Database
Option Explicit
Private Sub Command1_Click()
Me.Textnum = 1
CallOut Me.ActiveControl.Caption
Me.Txtnum1 = Textnum
Me.Txtno1 = txtNo
End Sub
Function CallOut(intTeller As Integer)
If Me.txtNo >= DLookup("[Numofgard]", "T_Numgard1") Then Me.txtNo = 0
Me.txtNo = Me.txtNo + 1
Me.Repaint
Call ReadOut(Me.txtNo, intTeller)
fServiceSave intTeller
StatusBarMsg ("Edit By ÀÒ³ØÇѲ¹ì ¾ÃÁ¿Ù ·Õè·Ó¡ÒÃä»ÃɳÕÂì¨Ñ§ËÇÑ´¹èÒ¹ 054 710178 µèÍ 16")
ReSizeForm Me
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyA
If Me.Txtno1 = 0 Then
DoCmd.CancelEvent
Else
Call Command01_Click
End If
Case vbKeyF2
If Me.Txtno2 = 0 Then
DoCmd.CancelEvent
Else
Call Command02_Click
End If
Case vbKeyF3
If Me.Txtno3 = 0 Then
DoCmd.CancelEvent
Else
Call Command03_Click
End If
Case vbKeyF4
If Me.Txtno4 = 0 Then
DoCmd.CancelEvent
Else
Call Command04_Click
End If
Case vbKeyF5
If Me.Txtno5 = 0 Then
DoCmd.CancelEvent
Else
Call Command05_Click
End If
Case vbKeyF6
If Me.Txtno6 = 0 Then
DoCmd.CancelEvent
Else
Call Command06_Click
End If
Case vbKeyB
If Me.Txtno7 = 0 Then
DoCmd.CancelEvent
Else
DoCmd.SetWarnings False
Call Command07_Click
'Debug.Print "1"
End If
Case vbKeyF8
If Me.Txtno8 = 0 Then
DoCmd.CancelEvent
Else
Call Command08_Click
End If
Case vbKeyF9
If Me.Txtno9 = 0 Then
DoCmd.CancelEvent
Else
Call Command09_Click
End If
End Select
End Sub
Private Sub Command01_Click()
Me.Command1.SetFocus
CallOut1 Me.ActiveControl.Caption
End Sub
Function CallOut1(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno1, intTeller)
End Function
Private Sub Command02_Click()
Me.Command2.SetFocus
CallOut2 Me.ActiveControl.Caption
End Sub
Function CallOut2(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno2, intTeller)
End Function
Private Sub Command03_Click()
Me.Command3.SetFocus
CallOut3 Me.ActiveControl.Caption
End Sub
Function CallOut3(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno3, intTeller)
End Function
Private Sub Command04_Click()
Me.Command4.SetFocus
CallOut4 Me.ActiveControl.Caption
End Sub
Function CallOut4(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno4, intTeller)
End Function
Private Sub Command05_Click()
Me.Command5.SetFocus
CallOut5 Me.ActiveControl.Caption
End Sub
Function CallOut5(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno5, intTeller)
End Function
Private Sub Command06_Click()
Me.Command6.SetFocus
CallOut6 Me.ActiveControl.Caption
End Sub
Function CallOut6(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno6, intTeller)
End Function
Private Sub Command07_Click()
Me.Command7.SetFocus
CallOut7 Me.ActiveControl.Caption
End Sub
Function CallOut7(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno7, intTeller)
End Function
Private Sub Command08_Click()
Me.command8.SetFocus
CallOut8 Mid(Me.ActiveControl.Caption, 2)
End Sub
Function CallOut8(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno8, intTeller)
End Function
Private Sub Command09_Click()
Me.command9.SetFocus
CallOut9 Mid(Me.ActiveControl.Caption, 2)
End Sub
Function CallOut9(intTeller As Integer)
Me.Repaint
Call ReadOut(Me.Txtno9, intTeller)
End Function
'Private Sub Form_Timer()
#If Win32 Then
Public Const SND_ASYNC& = &H1
Public Const SND_SYNC& = &H0
#Else
Public Const SND_ASYNC% = &H1
Public Const SND_SYNC% = &H0
#End If
#If Win32 Then
Public Declare Function sndPlaySound& Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long)
Public Declare Function mciExecute& Lib "winmm.dll" (ByVal lpstrCommand As String)
#Else
Public Declare Function sndPlaySound% Lib "mmsystem.dll" (ByVal lpszSoundName As String, ByVal uFlags As Integer)
Public Declare Function mciExecute% Lib "mmsystem.dll" (ByVal lpstrCommand As String)
#End If
Public Function PlaySound(PathToWavOrMidi$)
Dim lFlags As Long
Dim lPlay As Long
lFlags = SND_ASYNC& Or SND_SYNC& 'Returns to the begining of Wav or Midi
lPlay = sndPlaySound(PathToWavOrMidi$, 0) 'Plays the Wav or Midi Sound
End Function
Public Function PlaySound2(PathToWavOrMidi$)
Dim lPlay As Long
lPlay = mciExecute("Open " & PathToWavOrMidi$)
If lPlay = 0 Then
lPlay = mciExecute("Close")
End If
End Function