Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Chisisi Massri   on Dec 10 In MS Office Category.

  
Question Answered By: Alejandro Smith   on Dec 10

I got textbox  events to work with John Walkenbach's technique
described here: http://j-walk.com/ss/excel/tips/tip44.htm (which
incidentally implies that it might work with XL 97) by converting it
to work with textboxes  (code below) BUT, it appears that three events
associated with textboxes, viz. BeforeUpdate, Enter and Exit, are not
available since: "Exit isn't an event  of the textbox. It is an event
of the control (the container for the textbox)." ref:
http://www.excelforum.com/showthread.php?t=369201
which page also may contain something you can use.

All the other events  are available:
BeforeDragOver
BeforeDropOrPaste
Change
DblClick
DropButtonClick
Error
KeyDown
KeyPress
KeyUp
MouseDown
MouseMove
MouseUp

Perhaps you can work round it by using one of these?

Perhaps someone knows how to set up a class module for the control
(the container) rather than the textbox?

For what it's worth, the code  for, in this case, the change event:
In a class module called tbClass:

Public WithEvents TextBoxGroup As MSForms.TextBox
Private Sub TextBoxGroup_Change()
MsgBox "Hello there!"
End Sub

In a standard code module:

Sub ShowDialog()
UserForm1.Show
End Sub

In the UserForm1 code module:

Dim TextBoxes() As New tbClass
Private Sub UserForm_Initialize()
Dim TextBoxCount As Integer
Dim ctl As Control
' Create the TextBox objects
TextBoxCount = 0
For Each ctl In UserForm1.Controls
If TypeName(ctl) = "TextBox" Then
TextBoxCount = TextBoxCount + 1
ReDim Preserve TextBoxes(1 To TextBoxCount)
Set TextBoxes(TextBoxCount).TextBoxGroup = ctl
End If
Next ctl
End Sub

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 


Tagged: