次のことについて助けが必要です。CMpos というクラス モジュールを作成しました。
Public secId As String
次に、モジュールで、うまく機能している次のコード:
Sub testclass()
rijaantal_LenDump = Application.CountA(Sheets("Len_Dump").Range("A:A"))
kolomaantal_LenDump = Application.CountA(Sheets("Len_Dump").Range("1:1"))
Sheets("Len_Dump").Select
positions = Sheets("Len_Dump").Range(Cells(1, 1), Cells(rijaantal_LenDump, kolomaantal_LenDump))
kolomSecID = 8
Dim isc As New Collection
For i = 1 To rijaantal_LenDump
Set psecs = New CMpos
psecs.secId = CStr(positions(i, 8))
If Not Exists(isc, psecs.secId) Then isc.Add psecs, psecs.secId
Next i
Debug.Print isc.Count
MsgBox isc(8).secId
End Sub
ここで、別のサブルーチンからクラス module の値にアクセスしたいと思いますが、ここで MsgBox isc(8).secId (型の不一致) 行でエラーが発生します。Public isc As Collectionという行を使用して、別のモジュールにグローバル変数を作成しました。
Sub hjhk()
Call testclass
Dim isc As CMpos
Set isc = New Collection
MsgBox isc(8).secId
End Sub
私は何を間違っていますか?
ありがとうアミール