◎ Vbs Script Programming Tutorial II-how to start the first vbs script?

Source: Internet
Author: User

◎ Vbs Script Programming Tutorial II-how to start the first vbs script?

Like most computer tutorials !" The program starts our exercises. What? What does it mean? That is to say, the beginning of most computer programming tutorials is to write a small program. The result of executing this program is to display a line of text on the computer screen or DOS window: Hello world! Okay. Let's get started.

Open your notepad program and fill in the following information in the editing window:

Msgbox "Hello world! "

Click the "file" menu, click "save", set "Save in" to "desktop", and fill in KK in the "file name" column. vbs, click "save. Then, minimize the "Notepad" window, search for your saved KK. vbs on the desktop, and double-click it. The pop-up dialog box does not exist. Click OK. The dialog box disappears. It is ugly, but it is indeed the first script program you have written.

Note: In the above operations, the storage location is placed on the desktop, just for convenience, you can save it to other places, as long as you know where you saved it, what? It's nonsense. You can save it. No, I see more people I can't find my saved files. You can enter the file name at will, not necessarily write KK, as long as it complies with the Windows File naming rules, but the extension must be vbs. What? I don't know what the extension is? It is the part after "." In the file name. Simply put, the vbs script file must be named XXX. vbs, where XXX is random.

NOTE 2: What does this line mean in the notepad editing window?

Msgbox is a vbs built-in function. Each function can complete certain functions. You only need to enter the corresponding content in the corresponding part of the function according to the syntax requirements, this part of content is called a parameter. Of course, the result of function execution is called a return value. A function can have either a return value or a parameter. You don't need to know how a function works. You just need to know what this function can do.

Msgbox Syntax: msgbox "dialog box content", "dialog box title"

Open the file in notepad and enter the following in the editing window:

Msgbox "Hello world! "," System prompt"

Run the command to check the effect and position.

NOTE 3: If the execution fails, check your punctuation marks. All punctuation marks must be entered in English.

Of course, this script is too simple to even have the simplest interaction, so you can modify it like this:

Dim name

Name = inputbox ("enter your name:", "name ")

Msgbox name, "Your name is"

Save and run the command. Is the pop-up dialog box displayed? Enter your name and click OK. Have you seen the result?

Description: The first clause defines variables, and dim defines variables.

The format is dim variable 1, variable 2 ......,

Vbs only has one variable type, so you do not need to declare the variable type. The system automatically identifies the variable type.

NOTE 2: inputbox is a vbs built-in function that can accept input content. Its Syntax format is:

Inputbox ("dialog box content", "dialog box title ")

The second sentence means accepting user input and passing the input result to the variable name.

Now, the basic input and output functions of this script are available, and some simple functions can be completed. You can compile a simple script, copy the program> start, and restart the computer to check the result.


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.