..


Sponsored Links

The dialogs in VBScript

Article written by Luca Ruggiero
Page 1 of 2

The client-side VBScript provides the developer a large number of dialogs with the user, many more than its historic rival JavaScript, for two reasons:

1. dialog boxes that also uses standard JavaScript objects are part of the browser, and specifically not the language;

2. being a derivative of the VBScript programming language Visual Basic known, has at its disposal the windows box that has in turn available.

We start from the first, or those owners of all browsers, also available for JavaScript. There are three and are part of the window object, even if you do not need to specify it in code.

They are:

  • Alert - creates an alert box with one button to close the confirmation of the reading.
  • Confirm - it confirms the execution of the operation to be performed.
  • Prompt - prompts the user to enter text which will then be used for any purpose.
Let's see an example of Alert:





 <script type="text/vbscript">







 Alert "Hello, World!"







 </ Script>



Nothing is more simple and intuitive.

Let us now see a complete example of Confirm:






 <script type="text/vbscript">







 Dim confirms







 confirmation = confirm ("Click either button ...")







 Then if confirmed



    



 Alert "You clicked OK!"







 Else



    



 Alert "You clicked Cancel!"







 End If







 </ Script>



The item is stored in a variable and is made a condition to evaluate the choice made and perform different routines, or run only if the choice was made OK, as in the following:





 <script type="text/vbscript">







 Dim confirms







 confirmation = confirm ("Proceed with the execution of the script?")







 Then if confirmed



    



 'ROUTINE TO PERFORM ...







 End If







 </ Script>



We conclude with an example of a prompt:





 <script type="text/vbscript">







 Dim request







 Request = prompt ("Enter your name", "")







 If Request = "" Or IsNull (required) Then



    



 Alert "Hello friend!"







 Else



    



 End If







 </ Script>



The operation is virtually identical to the previous element and the second parameter of the prompt is "" To prevent it written into, by default, the special value "undefined".

In the same category ...
E-Learning
ASP Zero (Ebook) ASP Zero (Ebook)
Learning Microsoft ASP and VBScript from scratch. At only 29 €.
Visual Basic 6 (Course) Visual Basic 6 (Course)
Make Desktop Applications with VB6. From 39 €.
Sponsored Links