Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Useing Class structures and Events

I have created a class of textbox objects on a form with the following code;
Dim Listings() As New Class1
Dim listcount As Integer
Dim ctl As Control
listcount = 0

For Each ctl In Tag_Priority.Controls
If TypeName(ctl) = "TextBox" And ctl.Visible = True Then
listcount = listcount + 1
ReDim Preserve Listings(1 To listcount)
Set Listings(listcount).listgroup = ctl
End If
Next ctl

Class Module -
Public WithEvents listgroup As MSForms.TextBox
Private Sub listgroup_Change()

Bla Bla Bla

End sub

The problem is that the Change() event triggers each time a single digit is
modified in the included textboxs. It works great for my Bla Bla Bla code
when my textbox.text inputs are single digits 1,2,3, etc. but is a disaster
when I want to enter double digit numbers like 11,12,13, etc., each number is
its own textbox. I was hoping there is an event trigger or something I could
use that would trigger when I select another object either in that class or
on that form.

The form presents a list with associated priorities as texboxes, the idea is
that the user can change the textbox value which will then reprioritize the
list based on the new individual textbox inputs.

Im using Office 2000, I would apriciate any help that could be offered, Im
twisting my brain up in knots with logic statements. Thanks,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Useing Class structures and Events

Except in extremely limited cases, I find the change event (or the exit
event if you are so tempted) of textboxes to be practically useless for
any meaningful validation. The most reliable approach is to wait until
the user clicks the OK button and then validate the userform contents.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I have created a class of textbox objects on a form with the following code;
Dim Listings() As New Class1
Dim listcount As Integer
Dim ctl As Control
listcount = 0

For Each ctl In Tag_Priority.Controls
If TypeName(ctl) = "TextBox" And ctl.Visible = True Then
listcount = listcount + 1
ReDim Preserve Listings(1 To listcount)
Set Listings(listcount).listgroup = ctl
End If
Next ctl

Class Module -
Public WithEvents listgroup As MSForms.TextBox
Private Sub listgroup_Change()

Bla Bla Bla

End sub

The problem is that the Change() event triggers each time a single digit is
modified in the included textbox¤=3Fs. It works great for my Bla Bla Bla code
when my textbox.text inputs are single digits 1,2,3, etc. but is a disaster
when I want to enter double digit numbers like 11,12,13, etc., each number is
its own textbox. I was hoping there is an event trigger or something I could
use that would trigger when I select another object either in that class or
on that form.

The form presents a list with associated priorities as texboxes, the idea is
that the user can change the textbox value which will then reprioritize the
list based on the new individual textbox inputs.

I¤=3Fm using Office 2000, I would apriciate any help that could be offered, I¤=3Fm
twisting my brain up in knots with logic statements. Thanks,


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Useing Class structures and Events

Hi Dan,

The form presents a list with associated priorities as texboxes, the idea is
that the user can change the textbox value which will then reprioritize the
list based on the new individual textbox inputs.


Two potential alternatives come to mind:

1. Instead of reacting to the change event, have a separate 'Resort list'
button to do the reprioritisation.

2. Add a timer to the form (e.g. the IETimer.ocx available from the MS web
site), set to fire after (say) three seconds. Each time a text box is changed,
disable and reenable the timer. In the timer's event, reprioritize the list
then disable the timer again. The list should then update 'automagically' three
seconds after you stop typing.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


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
How do I draw chemical structures in Excel spreed sheet? James Charts and Charting in Excel 1 March 31st 09 08:29 AM
Importing File Structures to Excel asummers Excel Discussion (Misc queries) 3 February 23rd 06 01:42 PM
class events stop firing with ADO 2.8 ThankYou_jeff Excel Programming 4 November 14th 04 10:59 AM
Events, Class, Time Editing Dave Excel Programming 1 October 4th 04 11:06 PM
What events can be captured in a Class Module? Tom Ogilvy Excel Programming 4 September 8th 03 05:41 AM


All times are GMT +1. The time now is 05:18 AM.

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"