vbscript 哈希的用法 [2009年07月21日]

上一篇 / 下一篇  2009-07-21 17:42:59 / 个人分类:我的自动化学习

<script. language="vbs">
   dim map,i,sKey,sVal
   set map=CreateObject("scripting.dictionary")
   map.add "key-1","val-1"
   map.add "key-2","val-2"
   map.add "key-3","val-3"   
   
   '通过key找值
   sKey=inputbox("请输入你要查找的关键字")
   if map.Exists(sKey)  then
    sVal=map.item(sKey)
    msgbox "您要找的值是:" & sVal
   else
    msgbox "您要查找的值不存在!" 
   end if
  
   '通过值找key
   dim isFind
   isFind=false
   for each key in map.keys
     if(map.item(key)="val-2") then
       isFind=true
       sKey=key
       exit for
     end if
   next   
  
   if isFind then
     msgbox "找到了对应的key为:"+sKey
   else
      msgbox "没有找到!"
  end if
  
   set map=nothing
</script>

TAG:

yuanyuanmmm的个人空间 引用 删除 yuanyuanmmm   /   2010-01-06 14:22:16
偷了
 

评分:0

我来说两句

Open Toolbar