Text-To-Speech

The Code

Step 2 - Declaring the Constants

The next step is to add the code. This code will say the caption of the button and then run a program depending on which button you clicked. Add this code to the general declarations:

Const Notepad = "c:\windows\notepad.exe"
Const Wordpad = "C:\program files\accessories\Wordpad.exe"
Const Paint = "c:\windows\Pbrush.exe"
Const Calculator = "c:\windows\Calc.exe"
Const Volume = "c:\windows\Sndvol32.exe"
Const InternetExplorer = "C:\Program Files\Internet Explorer\Iexplore.exe"
Const SoundRecorder = "c:\windows\Sndrec32.exe"
Const Clipboard = "c:\windows\Clipbrd.exe"
Const Dialer = "c:\windows\Dialer.exe"
Const Solitaire = "c:\windows\Sol.exe"

Step 3 - The Code

Now add this code under the click event of btnNumbers:

spkSpeak.Speak "You clicked button number " & btnNumbers(Index).Caption & "."

Select Case Index + 1
  Case Is = 1
    Shell Notepad, vbNormalNoFocus
  Case Is = 2
    Shell Wordpad, vbNormalNoFocus
  Case Is = 3
    Shell Paint, vbNormalNoFocus
  Case Is = 4
    Shell Calculator, vbNormalNoFocus
  Case Is = 5
    Shell Volume, vbNormalNoFocus
  Case Is = 6
    Shell InternetExplorer, vbNormalNoFocus
  Case Is = 7
    Shell SoundRecorder, vbNormalNoFocus
  Case Is = 8
    Shell Clipboard, vbNormalNoFocus
  Case Is = 9
    Shell Dialer, vbNormalNoFocus
  Case Is = 10
    Shell Solitaire, vbNormalNoFocus
End Select

   Then next piece of code will speak the text typed in the text box. Add this code to the btnSpeak click event:

spkSpeak.Speak txtText.Text

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”