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

Properties and descriptions of the VBS object Dictionary

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

Share

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

This article mainly explains "VBS Object Dictionary attributes and descriptions," interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "VBS Object Dictionary attributes and descriptions"!

Dictionary

Objects that save data key and item pairs.

description

Dictionary objects are equivalent to PERL associative arrays. Items (which can be any form of data) are stored in arrays. Each item is associated with a unique key. A key is used to retrieve a single item, usually an integer or string, but not an array.

The following code demonstrates how to create a Dictionary object:

Dim d 'creates a variable. Set d = CreateObject("Scripting.Dictionary")d.Add "a", "Athens" 'Add keys and items. d.Add "b", "Belgrade"d.Add "c", "Cairo"

There is a special object in VBS-dictionary, which is a collection object. In general, I think of this special collection as an array, which can be used to complete basic tasks such as storing and manipulating data using built-in functions, without worrying about which rows and columns the data is in, but using a unique key to access or a database that can only run in memory, and only two fields are: key and item. In use, the field key is the index field.

set sdict=CreateObject("Scripting.Dictionary")sdict.add "a","apple"sdict.add "b","banana"sdict.add "c","copy"for each key in sdict.keysmsgbox "keyname" & key & "yes" & " = " & sdict (key)nextsdict.removeall

This script is very simple, that is, define an instance sdict of a dictionary object, and add three pieces of data, then enumerate each piece of data, and finally, empty the instance of the object.

A summary of the members of a Dictionary object

properties and descriptions

CompareMode Set or return key string comparison mode

Count read-only. Returns the number of key/entry pairs in the Dictionary

Item(key) Sets or returns the entry value of the specified key

Key(key)

methods and instructions

Add(key,item) Add key/item pair to Dictionary

Exists(key) Returns True if the specified key exists, False otherwise

Items() Returns an array containing all the entries in the Dictionary object

Keys() returns an array containing all the keys in the Dictionary object

Remove(key) removes a specified key/entry pair

RemoveAll() Delete all keys/entry pairs

At this point, I believe that everyone has a deeper understanding of the "VBS Object Dictionary attributes and descriptions," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

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