|
Option Explicit
Private opb() As class_mxout
'====================================
Private Sub UserForm_Initialize()
Dim n
ReDim opb(28)
For Each n In Array(3, 4, 26, 19, 18, 8, 7, 28, 27, 5, 6, 32, 31, 13, 12, 17, 16, 11, 10, 25, 24, 23, 22, 30, 29, 15, 14, 34, 33)
Set opb(n) = New class_mxout
With opb(n)
.Item = Me.Controls("OptionButton" & n)
.index = n
.caller = Me
End With
Next n
End Sub
'====================================
Public Sub op(ByVal index As Long)
Select Case index
Case 3
MsgBox "ok"
End Select
End Sub
'====================================
Private Sub UserForm_Terminate()
Erase opb
End Sub
'===============================クラス側======================
Private WithEvents myop As MSForms.OptionButton
Private MyIndex4 As Integer
Private MyCaller As Object
Public Property Let caller(newcaller As Object)
Set MyCaller = newcaller
End Property
Public Property Let Item(NewCtrl As MSForms.OptionButton)
Set myop = NewCtrl
End Property
Public Property Let index(NewIndex As Integer)
MyIndex4 = NewIndex
End Property
Private Sub myop_change()
Call MyCaller.op(MyIndex4)
End Sub
配列の数を増やしたらuserformが開くのですが、
Arrayの中のoptionbuttonは29個なので配列はこれでいいような
気がするのですが。
なぜ? ReDim opb(28)
|
|