|
'userform
----------------------------------------------------------------------------------
Private ufbt() As class_chikan01
Private cbox As class_chikan01
Private Sub UserForm_Initialize()
Dim ctl As MSForms.CommandButton
Dim lmoji_3 As MSForms.Label
Dim cbox As MSForms.CheckBox
Dim i as long
Dim J1(41)
J1(0) = "temp0"
↑
'実際のコードは41個分ずらずらと配列が続く
↓
J1(41)="temp41"
ReDim ufbt(41)
For i = 0 To 41
Set ctl = Controls.add("Forms.CommandButton.1", "button" & i)
Set ufbt(i) = New class_chikan01
With ufbt(i)
.Item = Me.Controls("button" & i)
.Index = i
.caller = Me
End With
Next i
Set cbox = Controls.add("Forms.CheckBox.1", "MyCheckBox01")
cbox.Caption = "selection"
Set cbox = New class_chikan01
With cbox
.Item2 = Controls("MyCheckBox01")
.caller = Me
End With
Set lmoji_3 = Controls.add("Forms.Label.1", "Label_3")
lmoji_3.Caption = "copyright"
Set ctl = Nothing
Set lmoji_3 = Nothing
----------------------------------------------------------------------------------
Private Sub cx()
MsgBox "ok"
End Sub
----------------------------------------------------------------------------------
Public Sub toch(ByVal Index As Integer)
Select Case Index
case 1
call ABC
case 2
call DE
end select
----------------------------------------------------------------------------------
Private Sub UserForm_Terminate()
Erase ufbt
Erase cbox
End Sub
'class_chikan01
--------------------'class_chikan01--------------------------------------------
Option Explicit
Private WithEvents mybt As MSForms.CommandButton
Private WithEvents mych As MSForms.CheckBox
Private MyIndex As Integer
Private MyCaller As Object
Public Property Let Item(NewCtrl As MSForms.CommandButton)
Set mybt = NewCtrl
End Property
----------------------------------------------------------------------------------
Public Property Let Index(NewIndex As Integer)
MyIndex = NewIndex
End Property
----------------------------------------------------------------------------------
Public Property Let caller(newcaller As Object)
Set MyCaller = newcaller
End Property
----------------------------------------------------------------------------------
Private Sub mybt_click()
Call MyCaller.toch(MyIndex)
End Sub
----------------------------------------------------------------------------------
'checkbox用
Public Property Let Item2(NewCtrl As MSForms.CheckBox)
Set mych = NewCtrl
End Property
----------------------------------------------------------------------------------
Private Sub mych_change()
Call MyCaller.cx
End Sub
----------------------------------------------------------------------------------
checkboxのみうまく動かない。
なぜ?
checkboxが変わった時にメッセージを出したいのでが。
|
|