我有一些看起来像这样的代码:
pos.Clutch = sh2.Cells(R, Clutch)
pos.Wiper = sh2.Cells(R, Wiper)
pos.Alternator = sh2.Cells(R, Alternator)
pos.Compressor = sh2.Cells(R, Compressor)
...
pos.Telephone = sh2.Cells(R, Telephone)
poss.Add pos
Run Code Online (Sandbox Code Playgroud)
poss是一个集合,Clutch,Wiper等是列索引(从1开始).这目前有效,但非常难看.我正在寻找一种方法来做这样的事......
Do While i <= classProperty.count
For each classProperty in pos
classProperty = sh2.Cells(R + 1, i)
Next classProperty
Loop
Run Code Online (Sandbox Code Playgroud)
显然这不起作用,但是有没有人对如何在类中完成大致相同的方法或集合有任何建议?