◎ Simple tutorial on vbs Script Programming-using a dictionary object

Source: Internet
Author: User

In vbs, a special object-dictionnary is a collection object. Generally, Xia thinks of this special set as an array and can use built-in functions to store and manipulate data and other basic tasks without worrying about the ranks of data, instead, it uses a unique key for access or a database that can only run in the memory. There are only two fields: 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. Keys

Msgbox "key name" & Key & "is" & "=" & sdict (key)

Next

Sdict. removeall

This script is simple. It defines the instance sdict of a dictionary object, adds three pieces of data, enumerates each piece of data, and finally clears the instance of the object.

Member summary of a dictionary object

Attributes and descriptions

Comparemode setting or string comparison mode of the Return key

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

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

Key (key) set the key value

Methods and instructions

Add (Key, item) to add a key/entry pair to Dictionary

Exists (key) if the specified key exists, true is returned; otherwise, false is returned.

Items () returns an array containing all entries in the dictionary object

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

Remove (key) deletes a specified key/entry pair

Removeall () delete all key/entry Pairs

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.