Creating customizable alert boxes using VBScript
A basic alert box in VBScript is produced using the following code:
<script language="VBScript"> MsgBox "Hello there" </script>
From this point on, however, things take on a life of its own, thanks to the optional parameters the above method supports. Case in point:
MsgBox "Hello there",64,"Greetings From JK"
Note the differing icon image to the left of the message, not to mention the title on top!
The below tables contain the supported values for the second parameter of MsgBox, which we'll show first, then explain how to use:
'Which buttons" Table:
|1||"Ok" AND "Cancel" buttons|
|2||"Abort", 'Retry", AND "Ignore" buttons|
|3||"Yes", 'No", AND "Cancel" buttons|
|4||"Yes" AND "No" button|
|5||"Retry" AND "Cancel" button|
Default button table:
|0||The first button from the left is the default button|
|256||The second button from the left is the default button|
|512||The third button from the left is the default button|
|768||The fourth button from the left is the default button|
Icon image table:
The above constants are interconnected and inseparable in their use. To specify which buttons and icons to equip your VB Alert box with, add up the relevant constant in each table (in total three constants), producing the parameter. Huh? For example, the box:
was produced using the parameter 0+0+64=64, since we wanted just an "Ok" button, that it be the default one, and lastly, have the "exclamation" icon image shown.
Making sure the message is across, here's another VB box, rendered using:
MsgBox "Incorrect",37,"Greetings From JK"
5+0+32 is where the 37 was derived from.
- Creating customizable alert boxes using VBScript (intro)
- Determining which button was pressed/ basic flow control
- VBScript and browser compatibility