LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Redim Preserve question

I tried to modify John Walkenbach's example in the link below (i.e. assigning
one subroutine to multiple buttons) to do the same task but for textboxes
instead of buttons:
http://www.j-walk.com/ss/excel/tips/tip44.htm

e.g. I have several textboxes, and I only want to assign a subroutine to 10
particular textboxes (namely txtCatch1PreY1 to txtCatch1PreY10). But my
attempt below seems to assign the subroutine to txtCatch1PreY1 only. Can
someone please help me spot where the problem is in my code?

' The following code is in Class Module 1
Public WithEvents SlopeTextboxGroup As MSForms.TextBox

Private Sub SlopeTextboxGroup_Change()
MsgBox "Hello from " & SlopeTextboxGroup.Name
End Sub


' The following code is in Module 1
Option Explicit

Dim TextBoxes() As New Class1

Sub ShowDialog()
Dim ctrl As Control
Dim TextboxCount As Integer

TextboxCount = 1
For Each ctrl In UserForm1.Controls
If TypeName(ctrl) = "TextBox" Then
If ctrl.Name = "txtCatch1PreY" & TextboxCount Then
TextboxCount = TextboxCount + 1
ReDim Preserve TextBoxes(1 To TextboxCount)
Set TextBoxes(TextboxCount).SlopeTextboxGroup = ctrl
End If
End If
Next ctrl
' Show UserForm1
UserForm1.Show
End Sub
 
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
VBA: What does Redim Preserve do in term of memory Charles Excel Programming 5 January 11th 08 09:53 AM
Redim Preserve form a userform? bobbo Excel Programming 1 October 20th 06 08:50 PM
redim preserve the second dimension in a two-dim array Arnold Klapheck Excel Programming 4 September 19th 06 02:10 PM
redim preserve [email protected][_2_] Excel Programming 3 December 15th 05 01:40 PM
Redim Preserve doesn't work Witek[_2_] Excel Programming 3 November 1st 04 11:34 PM


All times are GMT +1. The time now is 03:26 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"