I am wondering if there is a simple way to make the text to speech occur after the updating of label.text
If I have the following:
label.Text = "words words"
voice.Speak(label.Text)
I would like the label on the form to display “words words” before it speaks. I’m a beginner with vb, and the only thing I could come up with was to use a timer. Just wondering if there’s a simpler/more sophisticated solution. Thanks for helping
The trick is forcing the label to repaint itself with the new text before the
Speakmethod is called. Just because you assign a new text value to the control doesn’t ensure that it gets immediately repainted with that new text. Generally, the system waits until it is idle to do redraws, but you’re not letting it idle before you tell it to execute theSpeakmethod.The easiest way to fix this in .NET is to call the
Refreshmethod. All controls have it, and it does exactly what you want here. It forces the control to invalidate its client area (meaning the part that you can see, including the text) and redraw it immediately.Change your code to look like this: