English 中文(简体)
在VBA通过程序
原标题:Passing objects to procedures in VBA
  • 时间:2011-05-11 14:08:48
  •  标签:
  • excel
  • vba

我正在开发一个简单的工具,使我能够把多个CSV档案整理起来,并把它们放在一个“合并”的新的工作桌上。 这里是我的执行(我简化了它)和我的问题:

A级

private variables as types
property methods for accessing variables

B级

private variables as types
property methods for accessing variables

C级

Private cA as ClassA
Private cB as Collection   Collection of ClassB

D类: 我的部分问题

Private cC as Collection  Collection of ClassC
 Other member variables and their property get/lets

Public Sub AddA(A as ClassA)
    If cC.Item(A.foo) is Nothing then 
        dim tempC as ClassC
        set tempC = new ClassC
        tempC.A = A
    End if
End Sub

Main Module - Other half of my problem

Dim cC as New ClassC
 Initialize C级, this all works fine
Dim tempA as ClassA
Set tempA = new ClassA
 Set tempA properties
cC.AddA tempA   This is where my error is

I ve尝试将其通过为ByVal ByRef。 每一次都给我不同的错误(“错误论点类型”、“无效程序或论点”和“绝对不支持这种财产或方法”)

我对下一步工作没有任何想法,甚至审判了本应将直截面直射到ByVal或Beref的“th”,我记得,昨天。

感谢。

最佳回答

本条:

tempC.A = A 

means "assing to A property of tempC object the value of the default property of the A object."
Your A object apparently doesn t have a default property.

你实际上意味着:

Set tempC.A = A 

但即便如此,您也可进入一个私人领域<代码>A>。 页: 1 班级。 公布或公布<条码>SetA(>方法><条码> 页: 1 D 。

问题回答

暂无回答




相关问题
import of excel in SQL imports NULL lines

I have a stored procedure that imports differently formatted workbooks into a database table, does work on them then drops the table. Here is the populating query. SELECT IDENTITY(INT,1,1) AS ID ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

Excel date to Unix timestamp

Does anyone know how to convert an Excel date to a correct Unix timestamp?

C# GemBox Excel Import Error

I am trying to import an excel file into a data table using GemBox and I keep getting this error: Invalid data value when extracting to DataTable at SourceRowIndex: 1, and SourceColumnIndex: 1. As ...

Importing from excel "applications" using SSIS

I am looking for any tips or resources on importing from excel into a SQL database, but specifically when the information is NOT in column and row format. I am currently doing some pre-development ...

热门标签