VBA collection函数回传
生活随笔
收集整理的這篇文章主要介紹了
VBA collection函数回传
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
VBA collection函數回傳
- 參考: https://social.msdn.microsoft.com/Forums/en-US/62bb4c2b-0494-43c3-bb00-be6b40686aa4/vba-function-22914203092223820659-collection?forum=232
**關于VBA集合的使用網上中文資料很少,搜來搜去都是轉載的同一篇關于collection的介紹。
筆者在使用collection中發現,對于在函數function中定義了collection并返還,想要用sub過程調用該function獲得該collection的方法百思不得其解,后在微軟官網看到一種方法**
'關鍵在于這一句后面要加上As Collection ,不要加new Function ReturnCollection() As CollectionDim rtnCol As New CollectionrtnCol.Add "A" rtnCol.Add "B" Set ReturnCollection = rtnColEnd FunctionSub TestCollection()Dim testCol As CollectionSet testCol = ReturnCollectionFor i = 1 To testCol. CountDebug.Print testCol.Item(i)Next End Sub '# ——————————————————————————————————————程序猿在人行參考: https://social.msdn.microsoft.com/Forums/en-US/62bb4c2b-0494-43c3-bb00-be6b40686aa4/vba-function-22914203092223820659-collection?forum=232
總結
以上是生活随笔為你收集整理的VBA collection函数回传的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 零基础学习 Python 之条件语句
- 下一篇: [react] render方法的原理你