LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default design one event handler for multiple textboxes

And also, in the Form designer, you can select all textboxes then set the
MaxLength property to 30 just one time.



--

Hope that helps.

Vergel Adriano


"Vergel Adriano" wrote:

Hi Clara,

Yes, you can set the MaxLength property by code. Put this in the
UserForm_Initialize sub

Dim c As Control
For Each c In Me.Controls
If TypeOf c Is MSForms.TextBox Then
c.MaxLength = 30
End If
Next c


--

Hope that helps.

Vergel Adriano


"clara" wrote:

Hi Vergel,

Thanks a lot for your help! Even the max length limitation can be done
through setting the corresponding property, but for 30 textboxes it is still
tedious, can you figure out a way to do it just in one time?

Clara
--
thank you so much for your help


"Vergel Adriano" wrote:

You cannot have one event handler for multiple controls.. at least not in
Excel 2003, not sure about 2007. The most you can do is put all the logic in
one subroutine and call that in the individual event handlers. However, for
the example that you gave, you can just set the MaxLength property of the
textboxes to 30.


--

Hope that helps.

Vergel Adriano


"clara" wrote:

Hi all,

In a form, there are 30 textboxes who all need the limitation of 30 chars in
length. I know code can be put in the change event, but if I do it in that
way, I will use 30 event handlers even I can abstract the core logic into a
sub.Is there a way to use one handler for all text box controls

Clara
--
thank you so much for your help



 
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
event handler list travis Excel Programming 2 July 26th 06 02:48 PM
Event handler VBA Noob[_4_] Excel Programming 4 April 26th 06 03:49 PM
Event handler in a cell Man Utd Excel Programming 3 June 15th 05 07:44 AM
different IDispatch in event handler Dirk[_2_] Excel Programming 0 January 23rd 04 11:04 PM
Cell Event Handler David Excel Programming 3 January 19th 04 04:51 PM


All times are GMT +1. The time now is 02:03 PM.

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

About Us

"It's about Microsoft Excel"