Visual BASIC 也有類似 .Net 的 Arraylist 喲!

這可能對很多人來說不是秘密了,在 Microsoft Scrpting Runtime 裡面除了好用的 FileSystemObject 之外,另外就是 Dictionary 了。


先在 VB 內把 Microsoft Scrpting Runtime 給引用進來。

20040831_01.gif

之後就可以這樣用了:

Dim d As New Dictionary
d.Add "test", "測試"
d.Add 1, "我是數字"

另外也可以這樣給值:

d("test") = "測試"
d(1) = "我是數字"

要叫出來只要:

msgbox d("test")
msgbox d(1)

很方便用吧! ^_^

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

讚啊, 我用 FileSystemObject 那麼多年還不知道理頭有這個object 可用...@@
有同樣需求都是自己搞一個 Collection / Class 來做相同的用途...

感恩啊..站長..

發表您的評論

(必要)

(必要)