【软件测试自动化-VBScript基础讲座 4】== Dictionary 对象 ==

<!-- google_ad_client = "pub-9907354422678176"; /* 336x280, 创建于 09-11-6 */ google_ad_slot = "6466748603"; google_ad_width = 336; google_ad_height = 280; // -->

这次课程我们主要来讲解DICTIONARY对象的使用,讲解此对象的目的是为了后续在讲解《测试对象字典的应用》以及《面向对象的代码设计模式》做铺垫。因此虽然本次课程内容相对较为简单,但是DICTIONARY这个知识点是非常重要的,在后续的课程内容中我们会经常用到,因此希望大家在看完之后能够多多实践,掌握好它为后续课程打好扎实的基础。

  • Dictionary ---- 字典对象

说明:一个能够增删改的容器,同时也是一个COM组件

  • 添加项

Set dic=CreateObject("Scripting.Dictionary")
dic.Add "a","test was a"
dic.Add "b","test was b"
dic.Add "c","test was c"
MsgBox dic.Item("a") 'item可省略

  • 删除项

Set dic=CreateObject("Scripting.Dictionary")
dic.Add "a","test was a"
dic.Add "b","test was b"
dic.Add "c","test was c"
MsgBox dic.Count '3个
dic.Remove("a")
MsgBox dic.Count '2个
Msgbox dic("a") '已空

  • 修改项

Set dic=CreateObject("Scripting.Dictionary")
dic.Add "a","test was a"
dic.Add "b","test was b"
dic.Add "c","test was c"

MsgBox dic("a") '修改之前
dic.Item("a")="zzxxbb112"
MsgBox dic("a") '修改之后

你可能感兴趣的:(C++,c,软件测试,Google,VBScript)