`
touchinsert
  • 浏览: 1288015 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

【软件测试自动化-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") '修改之后

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics