,
Share this with your friends 
 

Visual Basic Create sound from System which is Typed in Text Box

0 ratings Views 299 
Author: Devendra_bb5c7007 (Devendra Singh)  View Profile |  View other solutions by this author

Question / Problem


input any A-z is sound is produce by the system or read it. we need sound file as wav/mp3 format.

Solution

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Private Sub Command1_Click()
Dim sel As String
'Dim play As Long
t = Text1.Text
Length = Len(t)
For I = 1 To Length
sel = Left(t, 1)
save = Right(t, Length - 1)
play = sel
Select Case play
Case "a"
play = PlaySound("C:\SOUNDS\a.WAV", 0, 0)
Case "b"
play = PlaySound("C:\SOUNDS\b.WAV", 0, 0)
Case "c"
play = PlaySound("C:\SOUNDS\c.WAV", 0, 0)
Case "d"
play = PlaySound("C:\SOUNDS\d.WAV", 0, 0)
Case "e"
play = PlaySound("C:\SOUNDS\e.WAV", 0, 0)
Case "f"
play = PlaySound("C:\SOUNDS\f.WAV", 0, 0)
Case "g"
play = PlaySound("C:\SOUNDS\g.WAV", 0, 0)
Case "h"
play = PlaySound("C:\SOUNDS\h.WAV", 0, 0)
Case "i"
play = PlaySound("C:\SOUNDS\i.WAV", 0, 0)
Case "j"
play = PlaySound("C:\SOUNDS\j.WAV", 0, 0)
Case "k"
play = PlaySound("C:\SOUNDS\k.WAV", 0, 0)
Case "l"
play = PlaySound("C:\SOUNDS\l.WAV", 0, 0)
Case "m"
play = PlaySound("C:\SOUNDS\m.WAV", 0, 0)
Case "n"
play = PlaySound("C:\SOUNDS\n.WAV", 0, 0)
Case "o"
play = PlaySound("C:\SOUNDS\o.WAV", 0, 0)
Case "p"
play = PlaySound("C:\SOUNDS\p.WAV", 0, 0)
Case "q"
play = PlaySound("C:\SOUNDS\q.WAV", 0, 0)
Case "r"
play = PlaySound("C:\SOUNDS\r.WAV", 0, 0)
Case "s"
play = PlaySound("C:\SOUNDS\s.WAV", 0, 0)
Case "t"
play = PlaySound("C:\SOUNDS\t.WAV", 0, 0)
Case "u"
play = PlaySound("C:\SOUNDS\u.WAV", 0, 0)
Case "v"
play = PlaySound("C:\SOUNDS\v.WAV", 0, 0)
Case "w"
play = PlaySound("C:\SOUNDS\w.WAV", 0, 0)
Case "x"
play = PlaySound("C:\SOUNDS\x.WAV", 0, 0)
Case "y"
play = PlaySound("C:\SOUNDS\y.WAV", 0, 0)
Case "z"
play = PlaySound("C:\SOUNDS\z.WAV", 0, 0)
End Select
t = save
Length = Length - 1
Next
msg = MsgBox("Do you want to quit?", vbYesNo + vbQuestion)
play = PlaySound("C:\SOUNDS\Theend.wav", 0, 0)
If msg = vbYes Then
End
ElseIf msg = vbNo Then
Text1.Text = ""
Text1.SetFocus
End If

End Sub

Private Sub Command1_GotFocus()
If Text1.Text = "" Then
Command1.Visible = False
Label2.Visible = True
play = PlaySound("C:\SOUNDS\Theend.wav", 0, 0)
Else
End If
End Sub

Private Sub Form_Load()
Label2.Visible = False
Command1.Visible = False
End Sub
Private Sub Text1_Change()
Command1.Visible = True
Label2.Visible = False
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode < 65 Or KeyCode > 90 Then
Text1.Text = ""
End If
End Sub

Private Sub Text1_LostFocus()
If Text1.Text = "" Then
Command1.Visible = False
End If
End Sub


Applies to

VB 2005

Rank It

Login to rank it

Report


Advertisement