質問
かVBコード(実際にVBA)を基本的には同一のタイプで動作します。ていると思い乾燥原理は良い指針のためのソフトウェアの開発を書きたいつの日常のすべての種類を操作します。たとえば、私は二つのスニペットのコードのようなことが、この
Dim i as Obj1
Set i = RoutineThatReturnsObj1()
i.property = newvalue
Dim i as Obj2
Set i = RoutineThatReturnsObj2()
i.property = newvalue
私のようにしたいことの両方を扱うインスタンス:
Sub MyRoutine(o as ObjectType, r as RoutineToInitializeObject, newvalue as value)
Dim i as o
Set i = r
i.property = newvalue
End Sub
またC++を用いたんを生成するテンプレートと言いなし学んでいかなければならない。ものを使用していVBA.私はかなり確かな能力なC++テンプレートのVBA言語の定義が他にある手段としても、同様の効果が得られ?私は推測する答えはないんだらさん、ありがとうございまでは一部機能のVBAと思います。
解決
あVB6います。更新した場合は、Visual Studioツールにオフィスです。当期純利用できるジェネリック医薬品:
Function MyRoutine(Of O)(R As Delegate, newvalue As Object) As O
Dim i As O = CType(r.Method.Invoke(Nothing, Nothing), O)
'you need another parameter to tell it which property to use'
' and then use reflection to set the value'
i.property = newvalue
return i
End Function
所属していません StackOverflow