VBS Tutorial: VBScript statement-With statement

Source: Internet
Author: User

With statement

Execute a series of statements on an object.

With object
statements
End With

Parameters

Object

Required. It can be an object name or a function whose return value is an object.

Statements

Required. To pairObjectOne or more commands.

Description

WithA statement can be used to execute a series of statements on a specified object, but the object name does not need to be repeated. For example, if you want to modify multiple attributes of an object, you can place all attribute assignment statements inWithIn the control structure, the object can be referenced only once instead of in every value assignment statement. The following example shows how to useWithStatement to assign values to the attributes of the same object.

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

Although the attribute operation is to useWithThe maximum number of statements. Its usage is not limited to this.WithBlock.

Note:Once you enterWithBlock,ObjectIt cannot be changed. Therefore, you cannot useWithStatement to change the values of several objects.

Can be nestedWithStatementWithThe block is written in another block. However, due to externalWithThe member of the block isWithBlock masking, regardless of the internalWithBlock to reference externalWithAny member of an object in the block must be referenced by a fully qualified object.

Key PointsDo not jump in or outWithBlock. IfWithThe statement in the block is not executed.WithOrEndStatement.

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.