首页 > 代码库 > VBA_Excel_教程:字典类型
VBA_Excel_教程:字典类型
VBA中的字典类型需要添加Microsoft Scripting Runtime引用,在Tools菜单下添加
Sub testDic() Dim strV As String Dim key As String key = "name" Dim value As String value = "关羽" Dim dic As Object Set dic = CreateObject("Scripting.Dictionary") ‘增 If dic.exists(key) = False Then dic.Add key, value End If Call read(dic) ‘删1 dic.Remove (key) Call read(dic) ‘删2:移除全部内容 ‘ dic.RemoveAll Call read(dic)End SubSub read(dic As Object) ‘遍历读取 For Each k In dic strV = dic.Item(k) Debug.Print strV NextEnd Sub
VBA_Excel_教程:字典类型
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。