VBS TUTORIAL: VBScript statement-with statement _vbs

Source: Internet
Author: User

With statement

Executes a series of statements on an object.

With object
End With



The required part. Can be either an object name or a function that returns a value to an object.


The required part. One or more commands that will be executed on object .


The WITH statement can be used to execute a series of statements on the specified object, but it does not need to be repeated to describe the object's name. For example, if you want to modify multiple properties of an object, you can place all the property assignment statements in the with control structure so that the reference to the object is only needed once, not in every assignment statement. The following example shows how to use the WITH statement to assign values to several properties of the same object.

With MyLabel  .Height = 2000  .Width = 2000  .Caption = "This isMyLabel"End With

Although a property operation is the most common case with a with statement, its usage is not limited to this. Any legitimate statements can be used in the With block.

Note that once you have entered the With block,object is immutable. Therefore, you cannot use A with statement to change the values of several objects.

The WITH statement can be nested, and a with block is written in another block. However, because the members of the outer with block are masked by the inner with block, whether the inner with block refers to any member of an object in an external with block, Must use a fully qualified object reference.

do not jump into or out of the With block. If you execute a statement in a with block without executing the with or end With statement, the result will cause an error or other unpredictable behavior.

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.