1. MsgBox function
The Information box function (MSGBOX) is a function of the commonly used output information. It displays information in a dialog box, waits for the user to click the button, and returns an integer indicating which button the user clicked. The syntax format is as follows:
Variable =msgbox (Information Content) [,< dialog box type > [,< Dialog title >]]
Description: < content > Specify the text that appears in the dialog box, using a hard return character (CHR13) in the information content to wrap the text. The width and height of the dialog box increase with the content, up to 1024 characters.
The < Dialog type > specifies the buttons and icons that appear in the dialog box, typically with three parameters. The values and meanings are shown in tables 3-3-1, table 3-3-2, and table 3-3-3. Table 3-3-1 Parameter 1: button appears
| Value |
constant |
Description |
| 0 |
vbOKOnly |
OK button |
| 1 |
vbOKCancel |
Ok and Cancel buttons |
| 2 |
Vbabortretryignore |
Stop, retry, and Ignore buttons |
| 3 |
vbYesNoCancel |
Yes, no and Cancel buttons |
| 4 |
vbYesNo |
Yes and no buttons |
| 5 |
Vbretrycancel |
Retry and Cancel button |
Table 3-3-2 Parameter 2: Icon type
| Value |
constant |
Description |
| 16 |
vbcritical |
Stop icon |
| 32 |
Vbquestion |
Question mark (? ) icon |
| 48 |
Vbexclamation |
Exclamation point (!) ) icon |
| 64 |
vbinformation |
Information icon |
Table 3-3-3 Parameter 3: Default button
| Value |
constant |
Description |
| 0 |
VbDefaultButton1 |
Specifies that the default button is the first button |
| 256 |
VbDefaultButton2 |
Specifies that the default button is the second button |
| 512 |
VbDefaultButton3 |
Specifies that the default button is the third button |
Note: The above three parameter values can be added to achieve the desired style.
2, the return value of MsgBox
The value returned by Msgbox () indicates which button is selected in the dialog box, such as the table 3-3-4
Table 3-3-4
| return value |
constant |
button |
| 1 |
vbOK |
OK button |
| 2 |
Vbcancel |
Cancel button |
| 3 |
Vbabort |
Stop button |
| 4 |
Vbretry |
Retry button |
| 5 |
Vbignore |
Ignore button |
| 6 |
Vbyes |
Is |
| 7 |
Vbno |
Whether |
3. Simple example
<title>Msgbox()函数的应用</title>
<body>
<script for="button1" event="onClick" language="VBScript">
a=Msgbox("明天去春游吗?",vbYesNo,"校长问大家")
if a =6 then
Msgbox "我很乐意与大家一起去春游。",Yes,"OK"
else
Msgbox "我明天工作忙,不能去,祝大家玩的开心。",Yes,"NO"
end if
</script>
<input type="button" name="button1" value="单击看校长提出什么问题">
4. Input box function
The input box function (InputBox) displays a dialog box that accepts user input and returns information that the user entered in the dialog box. The syntax format is:
Variable =inputbox (< information content > [, < Dialog title >] [, < default content >])
Annotations:
< content > Specify the text that appears in the dialog box. Use a hard return character (CHR (13)) in < content > to wrap the text. The height and width of the dialog box increases with the increase of < content >, up to 1024 characters. < dialog box title > refers to the title of the dialog box. < default content > You can specify the default text that appears in the text box of the input box. If the user clicks the OK button, the text (string) in the text box is returned to the variable, and if the user cancels the button, it returns a 0-length string.
If you omit some of the options, you must include the corresponding comma delimiter.
Simple example:
<title>InputBox()函数的应用</title>
<body>
<script language="VBScript" for="button" event="onClick">
myInput=Inputbox("请许下您的心愿","许愿","祝我全家平安!")
Msgbox myInput,vbYes,"这是我的心愿"
</script>
<div align="center"><input type="button" name="button" value="这是我的心愿"></div>
See the full set of ASP Getting started tutorials