我正在制作一个"测试程序"在使用vbscript的记事本中。我的第一个命令是"键入名称"我想说欢迎,然后是他们打字的名字。有什么建议?
这是代码:
Dim speaks, speech
speaks="Welcome"
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks
Dim msg, sapi
msg=InputBox("Type your name in the box below and press ENTER to proceed","Notepad","YOUR NAME HERE")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak msg
speaks="This is my test program"
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks
答案 0 :(得分:1)
您无需继续创建sapi.spvoice
的实例。只需创建一次并重复使用即可。您还可以将所有字符串合并为一个,这听起来就像您正在尝试的那样。
Set speech = CreateObject("sapi.spvoice")
msg = InputBox("Type your name in the box below and press ENTER to proceed", "Notepad", "YOUR NAME HERE")
speech.Speak "Welcome " & msg & ". This is my program."