5 Replies - 270 Views - Last Post: 15 July 2014 - 02:45 PM Rate Topic: -----

#1 markjc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 06-July 14

Creating typewriter effect to entered text with sound.

Posted 14 July 2014 - 02:51 PM

Hey all,
I realize that this is a topic that has been visited before and I have viewed many snippets of code regarding this but just wanted a fresh take on this issue with being able to state my specific concerns.

Currently I have a single line text box an enter button and a console window(a read only rich text box) on my form. When I type text and hit enter it adds that text to the bottom of the console. Similar to the function of an IM window. What's would like it to do is update in that wi Dow like a typewriter and play the click sound and ding fortune last character. Any ideas on how to do this? Thanks for all your help guys!!!

Is This A Good Question/Topic? 0
  • +

Replies To: Creating typewriter effect to entered text with sound.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8896
  • View blog
  • Posts: 33,364
  • Joined: 12-June 08

Re: Creating typewriter effect to entered text with sound.

Posted 14 July 2014 - 02:54 PM

I would imagine you would over ride the 'key pressed' event for the text-enter box.. so that each press sends character to what ever destination.. and when an 'enter key' is detected play a sound.


Quote

I realize that this is a topic that has been visited before and I have viewed many snippets of code regarding this but just wanted a fresh take on this issue with being able to state my specific concerns.

What was preventing you from accomplishing this with the multitude of snippets and topics from beforehand?
Was This Post Helpful? 0
  • +
  • -

#3 markjc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 06-July 14

Re: Creating typewriter effect to entered text with sound.

Posted 14 July 2014 - 04:30 PM

My apologies, I neglected to mention something. I don't whatnot the effect and sound to occur as the the user types. I want it to occur after the submission of text or press of the enter button if you will. This code is going in a class that will update the console with this effect whether it is user inputted text or text generated by the program.
Was This Post Helpful? 0
  • +
  • -

#4 Kizzle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 07-July 14

Re: Creating typewriter effect to entered text with sound.

Posted 15 July 2014 - 05:32 AM

Do you have a sound file on your computer? why don't you get the pressed key and if its enter then play the sound?
Have a look into:
My.Computer.Audio.Play("C:\file location\file name", AudioPlayMode.Background)


Or is this not what you are trying to achieve?
Was This Post Helpful? 0
  • +
  • -

#5 markjc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 06-July 14

Re: Creating typewriter effect to entered text with sound.

Posted 15 July 2014 - 09:36 AM

Not quite, I don't want the effect AS the user is typing. I want it as the data is afded to the other text box
Was This Post Helpful? 0
  • +
  • -

#6 IronRazer  Icon User is online

  • D.I.C Addict

Reputation: 196
  • View blog
  • Posts: 690
  • Joined: 01-February 13

Re: Creating typewriter effect to entered text with sound.

Posted 15 July 2014 - 02:45 PM

Hi,
You can try it like this. It works fine for me. You will need the two (.wav) sound files saved in the Debug folder of your projects folder or you can change the path to wherever your (.wav) files are located. You could also do it by adding the two (.wav) files to the projects Resources and then use My.Resources.NameOfYourFile instead of having them on the hard drive if you wanted.

Public Class Form1
    Private KeyClickSound As String = IO.Path.Combine(Application.StartupPath, "KeyClick.wav")
    Private SlideDingSound As String = IO.Path.Combine(Application.StartupPath, "SlideDing.wav")

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For Each c As Char In TextBox1.Text
            RichTextBox1.AppendText(c)
            RichTextBox1.Refresh()
            My.Computer.Audio.Play(KeyClickSound, AudioPlayMode.WaitToComplete)
        Next
        RichTextBox1.AppendText(vbNewLine)
        My.Computer.Audio.Play(SlideDingSound, AudioPlayMode.WaitToComplete)
        TextBox1.Clear()
        TextBox1.Select()
    End Sub
End Class



Hope it helps. B)

This post has been edited by IronRazer: 15 July 2014 - 02:49 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1