Thanks, Alex.
I have already found out by myself that I have to use WithEvent declared
variables ina class module. Strange that it is not always working by some
reason, i.e. for an Image control I am able to trap DblClick event,
however, for a TextBox declared in the same way I cannot trap Change
event...
Here is some source code, maybe I've made a mistake that I don't see
anymore?
-------------------------------------------------------------------------------
-- Class used to trap Image control DblClick event
-- this class is working and I can use it to get double clicks
-- for myImage
clsImage.cls
....
Option Explicit
Public Event DblClick(ByVal Cancel As MSForms.ReturnBoolean)
' the Image object used for depiction
Private WithEvents myImage As Image
' Assigns new image
Property Set Image(newImage As Image)
If myImage Is Nothing Then
Set myImage = newImage
Else
Set myImage = Nothing
Set myImage = newImage
End If
End Property
' Retrieves current image instance
Property Get Image() As Image
Set Image = myImage
End Property
Private Sub myImage_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox "Double click detected!"
End Sub
-------------------------------------------------------------------------------
-- Class I am trying to use to capture TextBox Change() event
-- and this is NOT working

(
clsTextBox.cls
....
' Published events
Public Event Change()
' TextBox to wrap
Private WithEvents myTextBox As TextBox
' Set TextBox reference
Property Set TextBox(newTextBox As Object)
If myTextBox Is Nothing Then
Set myTextBox = newTextBox
Else
' first discard old object
Set myTextBox = Nothing
Set myTextBox = newTextBox
End If
End Property
' Retrieve TextBox reference
Property Get TextBox() As Object
Set TextBox = myTextBox
End Property
Private Sub myTextBox_Change()
MsgBox "Change detected"
End Sub
-------------------------------------------------------------------------------
-- and here is how I instantiate these classes:
'...
' Adds a molecule to the project
Sub Test()
Dim myPage As Page
Dim myId as TextBox
Dim myImage As Image
Dim newTextBox as clsTextBox
Dim newImage As clsImage
' increase number of currently processed entries
iCount = iCount + 1
' add a page for new entry
Set myPage = frmMain.MultiPage1.Pages.Add("page" & iCount, "Entry " & _
iCount)
' add ID text box
Set myId = myPage.Controls.Add("Forms.TextBox.1", "tbId", True)
With myId
.Top = 1
.Left = 1
.Width = 15
End With
' add image thumbnail
Set myImage = myPage.Controls.Add("Forms.Image.1", "imgNewImage", True)
With myImage
.Top = 12
.Left = 18
.BorderStyle = fmBorderStyleSingle
.BackColor = &HFFFFFF
.SpecialEffect = fmSpecialEffectSunken
.Width = 240
.Height = 240
.ControlTipText = "Double-click here to edit the entry"
End With
' wrap new image by own class to trap double clicks
Set newImage = New clsImage
Set newImage.Image = myImage
' wrap Id text box by own class to trap changes
Set newTextBox = new clsTextBox
Set newTextBox.TextBox = myId
' Activate last added page
frmMain.MultiPage1.Value = iCount - 1
End Sub
-------------------------------------------------------------------------------
When I run the procedure, the Image and TextBox appears on the form.
However, double-clicks are trapped by clsImage whilst changes in text box
are not

((
Regards,
Alex