A simple example of VBScript page for VBScript tutorial 12th

Source: Internet
Author: User

A simple page

Use Microsoft? Internet Explorer allows you to view the pages created with the following HTML code. If you click the button on the page, you can see the running result of VBScript.

<HTML>
<HEAD> <TITLE> A simple homepage </TITLE>
<Script language = "VBScript">
<! --
Sub Button1_nClick
MsgBox "Mirabile visu ."
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3> A simple homepage </H3> <HR>
<FORM> <input name = "Button1" TYPE = "BUTTON" VALUE = "Click here"> </FORM>
</BODY>
</HTML>

The result is a bit simple: a dialog box displays a Latin phrase (meaning "looks pretty "). However, this Code actually does many things.

When Internet Explorer reads the page, it finds the <SCRIPT> mark to identify the VBScript code and save the code. When you click the button, Internet Explorer connects the button to the code and runs the process.

<SCRIPT> the Sub process in the tag is an event process. The process NAME consists of two parts: one part is the button NAME, that is, Button1 (obtained from the NAME attribute in the <INPUT> tag), and the other part is the event NAME, that is, nClick. The two parts are connected by underscores. When you click the button, Internet Explorer searches for and runs the corresponding event process, that is, Button1_nClick.

Internet Explorer defines events that can be used for Form Controls in the Internet Explorer Scripting Object Model document.

You can also use a combination of controls and processes on the page. VBScript and the form display some simple interactions between controls.

Other methods for appending code to an event

The above method may be the simplest and most commonly used, but you can also use the other two methods to attach VBScript code to the event. One way is to add shorter internal code to the tag of the definition control. For example, when you click the button, the following <INPUT> MARK performs the same operation as the previous example:

<Input name = "Button1" TYPE = "BUTTON"
VALUE = "Click here" nClick = 'msgbox "Mirabile visu." '>

Note that function calls are included in single quotes, and MsgBox function strings are included in double quotes. Multiple statements can be used as long as the statement is separated by a colon.

Another way is to specify specific controls and events in the <SCRIPT> tag:

<Script language = "VBScript" EVENT = "nClick" FOR = "Button1">
<! --
MsgBox "Mirabile visu ."
-->
</SCRIPT>

Because the <SCRIPT> tag specifies events and controls, you do not need to use Sub and End Sub statements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.