In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to flexible and practical VBS". In daily operation, I believe many people have doubts about how to use flexible and practical VBS. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "how to flexible and practical VBS"! Next, please follow the editor to study!
VBS is just an English abbreviation, the full name is Visual Basic Script Edition, that is to say, VBS is the script version of Visual Basic, many people say that VBS is a subset of VB. Because VBS is basically the same as Visual Basic in programming syntax and function. VBS can also achieve the general functions that Visual Basic can achieve, and the process is easier than Visual Basic, because only a text editor can complete VBS programming, and Windows's own notepad Notepad is fully competent.
Let's write a classic routine: hello world. What we want to achieve is the effect in figure 1, which requires only one statement. Specific practices are as follows: open notepad, enter "msgBox (" hello world ")" (figure 2) in the editing area, and then save the file with the extension VBS ("Save as type" select "all files" in the "file name" enter the file name including the extension, such as "hello world.vbs"), after saving is complete, double-click the saved file directly, and the effect will come out. Friends who have studied VB know that the msgbox function is one of the most commonly used functions in VB programming, and it can realize pop-up window prompts.
Figure 1
Figure 2
Where there is output, there will be input, and corresponding to msgBox is the input function InputBox, which is used to receive the user's input information and then return to the specified variable. Let's use another example to illustrate. Enter the following in the notebook:
Dim name
Name=InputBox ("Please enter the name of your Internet bar", "name")
MsgBox (name)
After saving, double-click to run, and the window shown in figure 3 appears.
Figure 3
Enter what you want to enter in the window (such as "grass network" in this example), click OK, and a prompt window will pop up showing what you have entered (figure 4).
Figure 4
Now let's have an in-depth understanding of the significance of the above content. Dim is the keyword for declaring variables in Visual Basic, and it is also applicable in VBS. The statement looks like this:
Dim variable name [As type]
The contents of the square brackets can be omitted (this is the meaning of the square brackets mentioned in later articles). If omitted, the variable you declare will be variant, and the data type of the variable will depend on the value you assign to the variable. If the value you assign to the variable is an integer, it will be an integer variable. The second statement "Name=InputBox (" Please enter your Internet bar name "," name ")" means that when the InputBox function is executed, the user input is assigned to the variable Name. "=" is the assignment symbol, which is different from the "=" in the number.
Variables are mentioned above, and for readers who have not learned programming, they may not know what variables are. In fact, in high-level language programming, in addition to variables, there are constants. To put it bluntly, constants and variables are named memory units, and when reading modified data, the data is accessed through the name of the memory cell. Specifically, a variable is the amount by which its value can change while the program is running. It is more flexible. Constants are constant in the operation of the program, which are generally divided into three types: direct constants and user-declared symbolic constants. Direct constants can be used without declaration, such as 123 is a direct constant, you can use it directly, but you can't change it, if you try to change it, such as 123-321, it will go wrong when the program runs. The constant declared by the user is to facilitate the reading or modification of the program, and the constant declared by the user is modified, then the values related to the constant of the declaration will be changed accordingly, instead of being modified one by one. The keyword of the constant declaration is Const, for example: const PI=3.14159. Let's write a program to calculate the area of a circle. Enter the following in notepad:
Const PI=3.14
Dim r,S
R=InputBox ("Please enter the radius of the circle you want to calculate", "radius")
S=PI*r*r
MsgBox ("the area of circle is" & s)
Save as a VBS file, a program for calculating the area of a circle is completed.
At this point, you must also have a preliminary understanding of VBS programming, to learn more in depth, but also to learn to choose structures and loop structures, which will be covered in later articles.
At this point, the study of "how to be flexible and practical VBS" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.