السلام عليكم
إليكم طريقة اخراج صوت عند الكتابة على text box
1- قم بإضافه folder اسمه Sounds داخل ال Debug
اضف ال class التالي لملفات المشروع :
Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal name As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)
End Sub
End Class2- قم بإضافه Textbox على ال Form ثم اضغط عليه مرتين وضع الكود التالي :
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
HappySound.PlaySoundFile(Application.StartupPath & "\Sounds\1.wav")
End Subوفي المرفقات تجدون المثال جاهز مع القليل من الاضافات