【问题标题】:Excel VBA Class variable emptying across function callsExcel VBA类变量跨函数调用清空
【发布时间】:2016-05-05 23:41:58
【问题描述】:

我有一个类模块,其中在顶部我声明了一个集合

Dim orderCol As New Collection

在所有这些常用变量声明的下方是公共函数和填充该订单集合变量的子函数。

调用该函数后,它会脱离上下文,而且我推测它是一个类变量,因此不会脱离上下文。

这里有一部分代码最终可以让我自动完成数小时痛苦的文书工作……

'变量声明结束

Public Function start() As String

    scrape_root_page
    Application.Wait (Now + TimeValue("0:00:01"))
    scrape_orders_list 'the orders collection variable gets filled up here
    setup_workbook_temp_sheet 'however when it reaches this line, that orders collection variable is out of context

请告诉我如何让我的 orderCol 变量在该 scrape_orders_list 函数中填满后保持可用?

谢谢!!!

【问题讨论】:

    标签: excel vba class


    【解决方案1】:

    在调用其他函数的同一个函数中初始化变量...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      • 2018-09-17
      • 2022-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多