InterviewSolution
| 1. |
Solve : vbs script, press cancel to exit?? |
|
Answer» Hi i have a vbs script as shown: Code: [Select]Dim message, sapiMaybe you don't understand what i REALLY want here. "Press cancel to exit, Press ok to speak message."That's exactly what it does. just CHANGE the Prompt of the InputBox.Quote from: BC_Programmer on May 12, 2010, 07:15:12 PMOk here is another task: Code: [Select]'Blank x=msgbox("Do really WANTED to run this program?",4096+64+4,"Confirm.") 'Blank Dim message, sapi Set sapi=CreateObject("sapi.spvoice") do message=InputBox("Enter the text you want spoken","Speak This") if message <> "" then sapi.Speak message loop until message= "" What script should i add at the 'Blank in order to exit the program when i click no? And i click yes to run the program?Code: [Select]If msgbox("Do really wanted to run this program?",4096+64+4,"Confirm.") = vbNo Then WScript.Quit End If Dim message, sapi Set sapi=CreateObject("sapi.spvoice") do message=InputBox("Enter the text you want spoken","Speak This") if message <> "" then sapi.Speak message loop until message= "" For readability, try using using constant names (vbInformation, vbSystemModal) instead of constant values (64, 4096). Quote from: Sidewinder on May 14, 2010, 12:39:19 PM Code: [Select]If msgbox("Do really wanted to run this program?",4096+64+4,"Confirm.") = vbNo Then Well thanks!! It works greate. Here is my code: Code: [Select]Do Dim message, sapi Set sapi=CreateObject("sapi.spvoice") If InputBox("Enter the text you want spoken","Speak This") = vbCancel then wscript.quit End if sapi.Speak message loop My code is wrong and i hope you can help me with it.Quote from: progmer on May 17, 2010, 09:35:57 PM Here is my code: Quote from: BC_Programmer on May 11, 2010, 09:53:30 PM If you press cancel, Inputbox returns an empty string.Quote from: BC_Programmer on May 17, 2010, 09:44:41 PM I hope anyone can help me with this...... press cancel, inputbox returns an empty string. press the "x" button, the script exit. This is actually what i want.pressing "X" on the prompt window also causes the Inputbox() function to return an empty string. |
|