我最近不得不深入研究一些VB6代码,我看到了这个模式:
dim o as obj
set o = new obj
Run Code Online (Sandbox Code Playgroud)
为什么不呢?
dim o as new obj
Run Code Online (Sandbox Code Playgroud)
我记得15年前有一个很好的理由,但我不记得它现在是什么.谁还记得吗?原因仍然有效吗?
我有一个表,我想转换该对象中该表的每一行。该对象将具有每列的属性。
我做了这个功能:
Public Function GetProducts() As Object
Set GetProducts = New Collection
Dim p As New ProductInfo
Dim rng As Range
Dim xRow As Range
Set rng = Sheet2.Range("A2:I" & Sheet2.Range("A2").End(xlDown).Row)
For Each xRow In rng.Rows
p.Id = xRow.Cells(1, 1).Value
p.Cod = xRow.Cells(1, 2).Value
p.Name = xRow.Cells(1, 3).Value
p.productType = xRow.Cells(1, 4).Value
p.norma = xRow.Cells(1, 5).Value
p.masina = xRow.Cells(1, 6).Value
p.masinaType = xRow.Cells(1, 7).Value
p.operatori = xRow.Cells(1, 8).Value
p.sectie = xRow.Cells(1, 9).Value
GetProducts.Add Item:=p, Key:=CStr(p.Id)
Next xRow
End Function
Run Code Online (Sandbox Code Playgroud)
比我尝试用此Sub检查功能: …