PDA

View Full Version : does not end the file?


wolfandcrow
12-18-2007, 12:49 PM
Ok I posted this question inside another question and never got an answer I have been searching Google and found nothing. So am submitting the question in its own topic.

I have a bit of code that plays a sound file when some text is typed into a rich text box.

My problem is I can’t have multiple words play different sound files in the same text box it just loops the sound file after the word that activates it.



if (txtMessage.Text.ToUpper().IndexOf("HOME") > -1)
{
playsound.SoundLocation = @"c:\simple.wav";
playsound.Play();
}

if (txtMessage.Text.ToUpper().IndexOf("HOPE") > -1)
{
playsound.SoundLocation = @"c:\simple.wav";
playsound.Play();
}


I have tried it in all of these events

Enter Event
GotFocus Event
KeyDown Event
KeyUp Event
KeyPress Event
Leave Event
LostFocus Event

some play the sound after every key stroke some do nothing. But none solve the problem I have?

oracleguy
12-18-2007, 06:32 PM
So to be clear, you want the sound to play once after the keyword is entered but if other things are entered in the box after it, you don't want the sound repeated?

wolfandcrow
12-18-2007, 06:47 PM
I type home it plays but every key stroke after home it plays. I need it to play once for each time i input the word home.

example

i need it to do this.

qwerty home(play sound) qwerty qwerty qwerty home(play sound) qwerty qwerty

what it's doing at the mo is.

qwerty qwerty home(play sound) qwerty(play sound) qwerty(play sound) qwerty(play sound)

so yes correct oracleguy

i hope that helps.