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 Set statement in VBS

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "the usage of Set sentences in VBS". In daily operation, I believe many people have doubts about the usage of Set sentences in VBS. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "the usage of Set sentences in VBS". Next, please follow the editor to study!

Assign an object reference to a variable or property, or associate an object reference with an event.

Set objectvar = {objectexpression | New classname | Nothing}

-or-

Set object.eventname = GetRef (procname)

Parameter objectvar

Required, variable or attribute name; conforms to the standard variable naming convention.

Objectexpression

Optionally, Expression with the same object name, another declared variable of the same object type, function, or method, which returns an object of the same object type.

New

The Keyword used to create a new instance of a class. If the objectvar contains a reference to an object, when a new reference is assigned to the object, the reference will be released. The New key is only used to create an instance of class.

Classname

Optional. The name of the class created. Use Class statements to define classes and their statements.

Nothing

Optional. Disassociates objectvar from any specified object or class. When no other variable references the previous reference object, assign objectvar to Nothing to release the system or memory resources associated with the previous reference object.

Object

Required. The name of the object associated with the event.

Event

Required. The event name of the function scope.

Procname

Required. A string containing the Sub or Function name associated with the event.

Description

In order for it to be effective, the objectvar must be consistent with the type of object assigned.

Dim, Private, Public, or ReDim statements declare only one variable that references an object. It's in use. Until the Set statement assigns a value to a specific object, there is no actual object to reference.

Typically, when you use the Set statement to assign an object reference to a variable, a copy of the object of that variable is not created. In fact, only one reference to the object is created. Multiple reference object variables can refer to the same object. Because these variables are references to the object, not to a copy of the object, any changes made in the object can be reflected in all variables that reference the object.

Function ShowFreeSpace (drvPath) Dim fso, d, s Set fso = CreateObject ("Scripting.FileSystemObject") Set d = fso.GetDrive (fso.GetDriveName (drvPath)) s = "Drive" & UCase (drvPath) & "-" s = s & d.VolumeName & "

"s = s &" FreeSpace: "& FormatNumber (d.FreeSpace/1024, 0) s = s &" Kbytes "ShowFreeSpace = sEnd Function

With the New keyword, you can create an instance of a class at any time and assign an object reference variable to it. The variables assigned to the instance of the class must be declared in advance using the Dim (or similar statement) statement.

At this point, the study of "the use of Set sentences in VBS" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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