John_David
asked on
beep function ... super easy
I can't get my "hello world" vbscript to work. I am running it with WSH. I copied most of it. Everything works but the beep and it is just annoying me.
here it is with sub
dim v
v = inputbox ("what is ur name?")
msgbox " hello, " & v
Beeep(5)
Sub Beeep(itimes)
dim itemp
For itemp = 1 to itimes
beep
next
end sub
>>>>>>> type mismatch beep
here is another way
dim v
v = inputbox ("what is ur name?")
msgbox " hello, " & v
beep
>>>>same thing type mismatch beep
I really just want to know why this beep doesnt work. I dont want to know how to run multiple functions to connnect to a beep.wav. I will learn that later. This of course worked without the beep.
ty,
jd
here it is with sub
dim v
v = inputbox ("what is ur name?")
msgbox " hello, " & v
Beeep(5)
Sub Beeep(itimes)
dim itemp
For itemp = 1 to itimes
beep
next
end sub
>>>>>>> type mismatch beep
here is another way
dim v
v = inputbox ("what is ur name?")
msgbox " hello, " & v
beep
>>>>same thing type mismatch beep
I really just want to know why this beep doesnt work. I dont want to know how to run multiple functions to connnect to a beep.wav. I will learn that later. This of course worked without the beep.
ty,
jd
Beep function is only available in VB, but not in VBScript (Microsoft Windows Script Technologies)
See this as well:
VBScript functions available in Visual Basic Scripting Edition
http://msdn.microsoft.com/library/en-us/script56/html/vtoriFunctions.asp
VBScript functions available in Visual Basic Scripting Edition
http://msdn.microsoft.com/library/en-us/script56/html/vtoriFunctions.asp
ASKER
my "Im a noob" book says one of the simplest vbscript statements is beep. Ill check the links u gave later. Too busy to go surfing.
thnx
thnx
Ryancys is right, in theory you cant do it however this will work! ;-)
'~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~
Set wshell=CreateObject("Wscri pt.Shell")
wshell.run "cmd /C " & chr(34) & "@echo " & chr(7) & chr(34),0,True
'~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~
Dom
'~~~~~~~~~~~~~~~~~~~~~~~~~
Set wshell=CreateObject("Wscri
wshell.run "cmd /C " & chr(34) & "@echo " & chr(7) & chr(34),0,True
'~~~~~~~~~~~~~~~~~~~~~~~~~
Dom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I sort of understand the top statment (I just don't know what Wscript.Shell is). Any chance of explaining (just a little bit) the statement in the sub?
ASKER
I'm good at other languages. I have a cs degree, but ur right....I am going nutz...lol
OK, first of all you gotta understand that VBScript is NOT the same as VB. It is a hugely scaled down version a much more complex language. To go through the book you've got you should chase down a copy of Visual Studio (and it sounds like your learning VB6 not .NET).
That said, because VBScript is less featured than VB, it is sometimes necessary to reference some outside tools. In this instance, to produce the beep requires running the code '@echo' and then the ascii character number 7 from a command line. (Don't ask why, it just works! :-P) If you were using VB you could just use the 'Shell' command which does the same thing however it is not available in VBScript. It is however available in WScript which is another scripting tool built into Windows (from 98 onwards I think).
The 'set WShell=CreateObject("WScri pt.Shell") ' line simply creates a new WScript Shell command and gives it a handle (WShell). Later, in the Sub when you want to make the beep sound, we simply call the Run method of the object with the parameters (in this case the command line to be run) and it accesses teh WScript method and executes.
Hope that was understandable! Good Luck.
Dom
That said, because VBScript is less featured than VB, it is sometimes necessary to reference some outside tools. In this instance, to produce the beep requires running the code '@echo' and then the ascii character number 7 from a command line. (Don't ask why, it just works! :-P) If you were using VB you could just use the 'Shell' command which does the same thing however it is not available in VBScript. It is however available in WScript which is another scripting tool built into Windows (from 98 onwards I think).
The 'set WShell=CreateObject("WScri
Hope that was understandable! Good Luck.
Dom