1.VBS There is only one data type-the variant is similar to a generic type, where specific types are materialized at the time of invocation2. Declaring variables can be used with the Dim statement, public statement, private statementDeclare multiple variables separated by commascan also be implicitly declared, and directly written, but not a good way, not recommended3. Declare the array Dim A (10). Starting from 0.Dynamic arraysDim Answer () Redim Preserve Answer (+)However, when using ReDim to
array so that it is variable in size. First, you do not have to specify the size when declaring an arrayDim VarName ()You can use the ReDim statement to set or reset the size of an array before the first use, and at any time thereafterReDim [Preserve] varname (subscripts) [, ...]The keyword Preserve makes VBScript keep existing data in a resized array. (If the new array is shorter than the original, the extra elements at the end are removed). If ther
The VBScript language provides two statements and an object to handle "Run-time errors", such as the next, 1.On error Resume Next statement, 2.On error Goto 0 statement, 3.Err object, below we will discuss in detail.
If the On Error statement is not used, any run-time error is fatal, that is, the result will cause an error message to be displayed and the operation aborted. A "allowed" error handler is a handler that is opened by the On Error statemen
Repeating code with loops
Loops are used to repeatedly execute a set of statements. Loops can be grouped into three categories: a class that repeats a statement before the condition becomes False, a class that repeats the statement before the condition becomes True, and another class repeats the statement at a specified number of times.
The following looping statements can be used in VBScript:
Do ... Loop: loops when (or until) the condition is True.
Foreigners write a class, such a small application, unless there is a special need, there is no need for modularity.
Generate a random number using ASP.
''**************************************************************************
"' Class:crandom
' Calls randomize to seed the random number generator.
' provides functions for returning ranged random integers or arrays of
' Ranged random integers.
"Calling Randomize to Seed" random number generator at the time the
' class is created seemed like a
Use VBScript script to modify the contents of a file, this applies to automated operations
' Create a new Replace.vbs script, the script reads as follows, when the program runs, enter three parameters: Find content, replace content, file
Copy Code code as follows:
Dim FileName, Find, ReplaceWith, FileContents, dfilecontents
Find = wscript.arguments (0)
replacewith = wscript.arguments (1)
FileName = WScript.Arguments (2)
' Read the
Busy looking for a job until the weekend is free. Now to continue the design of our VBScript class. We've designed a simple date class the last time, but there are some
On the issue. Now we're going to change our design for these issues. The problem we have to solve this time is:
1, if the user specified classdate is not a date type, then the date will become January 1, 1900;
2. If more than one date is displayed, the name of the form object cannot be
Using Loop statements
Loops are used to repeatedly execute a set of statements. Loops can be grouped into three categories: a class that repeats a statement before the condition becomes False, a class that repeats the statement before the condition becomes True, and another class repeats the statement at a specified number of times.
The following looping statements can be used in VBScript:
Do ... Loop: loops when (or until) the condition is True.
Whil
Description Property
Returns or sets a descriptive string associated with the error.
object.Description [= stringexpression]
Parameters
Object
The Err object.
stringexpression
A string expression containing the error description.
Description
The Description property contains a short description of the error. This property is used to prompt the user for errors that you cannot or do not want to handle. When a user-defined error is generated, the brief description of this error is assigned
HelpFile Property
Sets or returns the full valid path of the Help file.
object.HelpFile [= contextID]
Parameters
Object
Required option. The Err object.
ContextID
Options available. The full valid path of the Help file.
Description
If you specify a Help file in HelpFile , the file is called automatically when the user clicks the Help button (or presses the F1 key) in the error message dialog box. If the HelpContext property contains a valid context ID for the specified file, the topic is automat
Number Property
Returns or sets a value specifying an error. number is the default property of the Err object.
object.Number [= errornumber]
Parameters
Object
The Err object.
ErrorNumber
An integer that represents the VBScript error number or SCODE error value.
Description
When a user-defined error is returned from the Automation object, the selected number is added as an error code to the constant vbObjectError to set the Err.Number.
The f
declaring a constant in this way, if the public or Private keyword is used, the keyword is valid for all constants in the row.
variables, user-defined functions, or VBScript intrinsic functions (such as Chr) cannot be used in a constant declaration. By definition, they cannot be constants. In addition, you cannot create constants from an expression that contains an operator, that is, only simple constants are allowed. A constant declared in a Sub or
After the use of QTP automated testing, often need to write test results in Excel, here is a number of commonly used to Excel operation methods are summarized, sorted, easy to use when consulted. Office Excel Version 2003 is supported and version 2007 is not supported.
VBScript code
On Error Resume Next Dim filename, sheetname, Text, Excelapp, excelbook, excelsheet filename = "D:/book1.xls" Sheetnam E = "new table" Text = "Hello QTP!"
Hello, qui
Can VBScript pass parameters by reference?
For example
function DDD (str)
Str=str "12345"
End Function
Abc= "54321"
Want to turn ABC into "5432112345" by DDD (ABC)
How to change it?
Answer:
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Today, on the 2008 R2 64-bit server system, when running the VBS file, the following prompts
---------------------------
Windows script Host
---------------------------
scripts: C:\Users\ Administrator\desktop\vbs_cf.vbs
Line: ten
characters: 1
Error: provider not found. The program may not be installed correctly.
code: 800a0e7a
Source: ADODB. Connection
In 2003, the normal operation of the program, why in the 08 can not use it, after the original is because of the 64-bit can not run di
VBScript code to get CPU usage through WMI
Niang, search the keyword "WMI CPU usage", get all Is "Python uses WMI monitor system-CPU Usage", do not look, certainly again collect.
Python is powerful, but invoking WMI is more "authentic" than using VBS.
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject ("winmgmts:\\" StrComputer "\root\cimv2")
Set colitems = objWMIService.ExecQuery ("SELECT * from Win32_Processor", "+") for
Vbscript| Object | The display is based on the code modified by MS, currently does not support editing, you can sort, query, pagination display
Class Classdatagrid
Private M_strsql
Private M_strconn
Private M_strrowcolor1
Private M_strrowcolor2
Private M_strmode
Private M_strprocesspage
Private M_strtitle
Private M_strrsname
Private M_strfindfields
Public Property Get SQL ()
SQL = M_strsql
End Property
Public Property Let SQL (strSQL)
M_strsql = s
Vbscript|visual
Variable range (Variable Scope) Visual Basic.NET allows the local variable to support the block range, that is, the variables declared in the loop or If, and so on, are not visible externally, so if the code writes the following imports System
Namespace MyNamespace
Module MyModule
Sub Main ()
Dim J As Integer
For J=1 to 10
If True Then
Dim I as Integer
I=i+1
Console.WriteLine ("I= in the Interior" CStr (i))
End If
Console.WriteLin
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.