Procedures in VBScript. FunctionsIn the below example, the variable minutes gets the number of minutes returned by the function minute with seconds as argument. minutes=minute(seconds) Intrinsic FunctionsIn addition to creating your own function procedures for use in your scripts, you can use a number of intrinsic function procedures that are built into VBScript. These functions include string operations, conversions, math functions, time and date functions, and Boolean functions. Understanding these functions will benefit you greatly as you begin to write larger and more complex scripts. You've already used the MsgBox function to test the VBScript language features that we've discussed so far. The message box is useful when you want to notify a user that an event has occurred. You can specify the buttons shown in the dialog, and the function returns a value that indicates which button was clicked: MsgBox(prompt, buttons, title, helpfile, context) The buttons, helpfile and context arguments in the MsgBox function are optional. Let's try the simple code to define which value is returned by MsgBox function while clicking various buttons. <html>
<head>
<script language="VBScript">
sub ShowMsgBoxValue
'Start a subroutine
r=msgbox("Click any button",VBYesNoCancel)
'calling a MsgBox function within ShowMsgBoxValue subroutine
document.write(r)
color="#008000">'Write a returned value
End Sub 'end of procedure
</script>
</head>
<body onload="ShowMsgBoxValue">
</body>
</html>The function is called by ShowMsgBoxValue subroutine which in turn is called after document loading. The returned value is indicated in the document. In practice, the user might process the returned value to give a response depending on the clicked button.
The copyright of the article Procedures in VBScript. Functions in VB Script is owned by Maxim Karetnikov. Permission to republish Procedures in VBScript. Functions in print or online must be granted by the author in writing.
Go To Page: 1 2 Articles in this Topic Discussions in this Topic |