投稿日 | : 2003/03/28(Fri) 12:45 |
投稿者 | : Lantern |
Eメール | : |
URL | : |
タイトル | : Re: クラスは遅い? |
コレクションを使用していると遅いです。
また、クラスの参照を頻繁に行うコードだと遅いです。
簡単なクラスの使い方例です。参考になればと思います。
'MDI等
Private clsChild() As Class1
Private Sub Task1()
ReDim clsChild(2) As Class1
Set clsChild(0) = New Class1
Set clsChild(1) = New Class1
Set clsChild(2) = New Class1
Call LongTask(clsChild(0))
Call LongTask(clsChild(1))
Call LongTask(clsChild(2))
End Sub
Private Sub LongTask(ByRef cChild As Class1)
Dim udtChild As typChild
'udtChildにファイル読み込み
cChild.uChild = udtChild
End Sub
'クラス
Option Explicit
Private udtChild As typChild
Friend Property Let uChild(ByRef newVal As typChild)
udtChild = newVal
End Property
Friend Property Get uChild() As typChild
uChild = udtChild
End Property
Public Property Let ChildA(ByVal newVal As Integer)
udtChild.uChildA% = newVal%
End Property
Public Property Get ChildA() As Integer
ChildA = udtChild.uChildA%
End Property
Public Property Let ChildB(ByVal newVal As Long)
udtChild.uChildB& = newVal&
End Property
Public Property Get ChildB() As Long
ChildB = udtChild.uChildB&
End Property
Public Property Let ChildC(ByRef newVal() As Double)
udtChild.uCHildC#() = newVal#()
End Property
Public Property Get ChildC() As Double()
ChildC = udtChild.uCHildC#()
End Property
'モジュール
Public Type typChild
uChildA As Integer
uChildB As Long
uCHildC() As Double
End Type