Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Textbox object event - Help please

HI Everyone...

I've been struggling with this for awhile and still don't understand why
this won't work. Any help in making it work would be appreciate...

1. Code adds frame containing textbox with events for the textbox to
worksheet. This works.

2. Class changes text property of textbox to "aaa" when textbox added. Text
gets displayed using TB_Change() event. This works.

3. If I change the text in textbox to something else, the textbox change
event doesn't fire to display changed text.

--------- Worksheet -----------
Private mcolEvents As Collection
Private clsEvents As clsTxt
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim objFrame As OLEObject
Dim objTextBox As Control

If mcolEvents Is Nothing Then
Set mcolEvents = New Collection
End If

Set objFrame = ActiveSheet.OLEObjects.Add(classtype:="Forms.Frame .1")
Set objTextBox = objFrame.Object.Controls.Add("Forms.Textbox.1")
objFrame.Activate

Set clsEvents = New clsTxt
Set clsEvents.TBControl = objFrame.Object.Controls(0)
mcolEvents.Add ctbnew

End Sub

--------- Class Module -----------
Option Explicit
Public WithEvents TB As MSForms.TextBox
Private Sub TB_Change()
MsgBox TB.Text
End Sub
Public Property Set TBControl(objNewTB As MSForms.TextBox)
Set TB = objNewTB
MsgBox TB.Name
TB.Text = "aaa"
End Property

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Textbox object event - Help please

Hi
Did you create an instance of your class module? long time since I've
done anything with class modules - try searching this group for
"create an instance" or "instantiate" maybe? Probably in Excel
2000/2003/2007? VBA by Green et al too.
regards
Paul

On Apr 12, 5:57*pm, sarndt wrote:
HI Everyone...

I've been struggling with this for awhile and still don't understand why
this won't work. *Any help in making it work would be appreciate...

1. Code adds frame containing textbox with events for the textbox to
worksheet. *This works.

2. Class changes text property of textbox to "aaa" when textbox added. *Text
gets displayed using TB_Change() event. *This works.

3. If I change the text in textbox to something else, the textbox change
event doesn't fire to display changed text. *

--------- Worksheet -----------
Private mcolEvents As Collection
Private clsEvents As clsTxt
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

* * Dim objFrame As OLEObject
* * Dim objTextBox As Control

* * If mcolEvents Is Nothing Then
* * * * Set mcolEvents = New Collection
* * End If

* * Set objFrame = ActiveSheet.OLEObjects.Add(classtype:="Forms.Frame .1")
* * Set objTextBox = objFrame.Object.Controls.Add("Forms.Textbox.1")
* *objFrame.Activate

* * Set clsEvents = New clsTxt
* * Set clsEvents.TBControl = objFrame.Object.Controls(0)
* * mcolEvents.Add ctbnew

End Sub

--------- Class Module -----------
Option Explicit
Public WithEvents TB As MSForms.TextBox
Private Sub TB_Change()
* * MsgBox TB.Text
End Sub
Public Property Set TBControl(objNewTB As MSForms.TextBox)
* * Set TB = objNewTB
* * MsgBox TB.Name
* * TB.Text = "aaa"
End Property


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Textbox object event - Help please

I did. Not sure how to make this work. Even tried removing the code out of
the worksheet_selection change event and put it in a module. Still can't
figure out how to make this work.

"Paul Robinson" wrote:

Hi
Did you create an instance of your class module? long time since I've
done anything with class modules - try searching this group for
"create an instance" or "instantiate" maybe? Probably in Excel
2000/2003/2007? VBA by Green et al too.
regards
Paul

On Apr 12, 5:57 pm, sarndt wrote:
HI Everyone...

I've been struggling with this for awhile and still don't understand why
this won't work. Any help in making it work would be appreciate...

1. Code adds frame containing textbox with events for the textbox to
worksheet. This works.

2. Class changes text property of textbox to "aaa" when textbox added. Text
gets displayed using TB_Change() event. This works.

3. If I change the text in textbox to something else, the textbox change
event doesn't fire to display changed text.

--------- Worksheet -----------
Private mcolEvents As Collection
Private clsEvents As clsTxt
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim objFrame As OLEObject
Dim objTextBox As Control

If mcolEvents Is Nothing Then
Set mcolEvents = New Collection
End If

Set objFrame = ActiveSheet.OLEObjects.Add(classtype:="Forms.Frame .1")
Set objTextBox = objFrame.Object.Controls.Add("Forms.Textbox.1")
objFrame.Activate

Set clsEvents = New clsTxt
Set clsEvents.TBControl = objFrame.Object.Controls(0)
mcolEvents.Add ctbnew

End Sub

--------- Class Module -----------
Option Explicit
Public WithEvents TB As MSForms.TextBox
Private Sub TB_Change()
MsgBox TB.Text
End Sub
Public Property Set TBControl(objNewTB As MSForms.TextBox)
Set TB = objNewTB
MsgBox TB.Name
TB.Text = "aaa"
End Property


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox KeyUp event Boog[_3_] Excel Programming 6 July 6th 09 11:16 AM
TextBox Event Error Stephen Newman[_2_] Excel Programming 7 July 18th 08 02:36 PM
How To Get An Event To Run When I Exit A TextBox Minitman[_4_] Excel Programming 7 October 22nd 04 11:27 PM
help with textbox change event N E Body Excel Programming 1 October 14th 04 10:07 PM
Textbox change event Ian Mangelsdorf Excel Programming 2 April 17th 04 09:30 AM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"