3.VBScript Foundation

Source: Internet
Author: User

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 invocation

2. Declaring variables can be used with the Dim statement, public statement, private statement

Declare multiple variables separated by commas

can also be implicitly declared, and directly written, but not a good way, not recommended

3. Declare the array Dim A (10). Starting from 0.

Dynamic arrays

Dim Answer () Redim Preserve Answer (+)

However, when using ReDim to declare the length, preserve represents the content before saving

4. Solve the problem of Chinese garbled, using ANSI code can

Sub MS ()     Dim answer    Answer=MsgBox(" Chinese! ",1,"Example")End SubMs

The effect is as follows:

5. Create Constants

Const age = 20

6. Array length

UBound: The maximum value of the array index.
LBound: Array index minimum value.
Desire array actual length, should be UBound (array) +1

The 7.VB return value is an array, and the return value is returned by the function name

X=getarr (9)'Call the Getarr procedure to return an array of 10 (0-9) elements and assign a value to x fori =0  to UBound(x)'enumerates the arrays that were just returnedArrstr=arrstr &"Getarr ("& I &")="& X (i) &vbCrLfNextMsgboxArrstr'Show ResultsFunctionGetarr (x)ReDimF (x)'dynamically adjust array size by variable fori =0  toXF (i)=Rnd 'Generate random variablesNextGetarr=f'Array is assigned to the return valueEnd Function


8. Functions can be declared using sub and function, but sub has no return value, and function has a return value

3.VBScript Foundation

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.