Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The usage of With statement in VBS

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "the use of With sentences in VBS". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Executes a series of statements against an object.

With object

Statements

End With

Parameter object

The necessary part. It can be an object name or a function that returns a value as an object.

Statements

The necessary part. One or more commands to be executed against object.

Description

The With statement can be used to execute a series of statements against a specified object without repeating the name of the object. For example, if you want to modify multiple properties of an object, you can place all attribute assignment statements in the With control structure so that the object needs to be referenced only once, rather than in each assignment statement. The following example shows how to use the With statement to assign several properties of the same object.

With MyLabel .height = 2000 .width = 2000 .Caption = "this is MyLabel" End With

Although attribute manipulation is the most frequently used case of With statements, its use is not limited to this. Any legal statement can be used in a With block.

Note that once you enter the With block, the object is immutable. Therefore, you cannot use a With statement to change the values of several objects.

You can write one With block in another using a nested With statement. However, because the members of the external With block are masked by the internal With block, no matter what member of an object in the external With block is referenced by the internal With block, a fully qualified object reference must be used.

The point is not to jump into or out of With blocks. If a statement in a With block is executed without a With or End With statement, the result is an error or other unpredictable behavior.

This is the end of the introduction to "the use of With sentences in VBS". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report