vb中,一个按钮,两个文本框,点击按钮实现同时播放文本框内容
“Devil组”引证GPT后的撰写:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' 播放文本框1中的内容
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Beep)
My.Computer.Speech.Speak(TextBox1.Text)
' 播放文本框2中的内容
My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Beep)
My.Computer.Speech.Speak(TextBox2.Text)
End Sub
在按钮的点击事件处理程序中使用了 My.Computer.Audio.PlaySystemSound 和 My.Computer.Speech.Speak 函数来播放文本框中的内容。PlaySystemSound 函数播放系统声音,Speak 函数将文本转换为语音并播放。首先播放了一个系统声音来提示用户,然后使用 Speak 函数播放文本框中的内容。