Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with For Each ... Next and control

I have a form that contains a Multipage control, with 4 pages, and about 5
textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
"For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "TextBox" Then" to go through the controls on the
form and only look for the textboxes.

My problem is that I am looking for a way to do the textboxes for before
the other controls or if there is a way to tell the programme which controls
to start with.
I want it to start with the textboxes on the first page of the Multipage,
then the textboxes on the second page and so on.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Help with For Each ... Next and control

On Sep 16, 11:36 am, Ayo wrote:
I have a form that contains a Multipage control, with 4 pages, and about 5
textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
"For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "TextBox" Then" to go through the controls on the
form and only look for the textboxes.

My problem is that I am looking for a way to do the textboxes for before
the other controls or if there is a way to tell the programme which controls
to start with.
I want it to start with the textboxes on the first page of the Multipage,
then the textboxes on the second page and so on.


Hello Ayo,

This macro steps through each page of the MultiPage control and counts
the number of TextBoxes on each page, if any. After each page is
examined, a MessageBox displays the count. The macro was placed in the
UserForm Click event. You can use this code as template for your own.

Private Sub UserForm_Click()

Dim Ctrls As Object
Dim I As Long, N As Long
Dim txtbox As Object

For I = 0 To UserForm1.MultiPage1.Pages.Count - 1
Set Ctrls = UserForm1.MultiPage1.Pages(I).Controls
For Each txtbox In Ctrls
N = N + 1
Next txtbox
MsgBox "Page(" & I & ") has " & N & " TextBoxes"
N = 0
Next I

End Sub

Sincerely,
Leith Ross

  #3   Report Post  
Posted to microsoft.public.excel.programming
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default Help with For Each ... Next and control

Thanks a lot Leith. I think this might actually do the trick.

"Leith Ross" wrote:

On Sep 16, 11:36 am, Ayo wrote:
I have a form that contains a Multipage control, with 4 pages, and about 5
textboxes, 5 labels and 5 commandbuttons on each page. I am trying to use
"For Each ctl In frmOpenFiles.Controls
If TypeName(ctl) = "TextBox" Then" to go through the controls on the
form and only look for the textboxes.

My problem is that I am looking for a way to do the textboxes for before
the other controls or if there is a way to tell the programme which controls
to start with.
I want it to start with the textboxes on the first page of the Multipage,
then the textboxes on the second page and so on.


Hello Ayo,

This macro steps through each page of the MultiPage control and counts
the number of TextBoxes on each page, if any. After each page is
examined, a MessageBox displays the count. The macro was placed in the
UserForm Click event. You can use this code as template for your own.

Private Sub UserForm_Click()

Dim Ctrls As Object
Dim I As Long, N As Long
Dim txtbox As Object

For I = 0 To UserForm1.MultiPage1.Pages.Count - 1
Set Ctrls = UserForm1.MultiPage1.Pages(I).Controls
For Each txtbox In Ctrls
N = N + 1
Next txtbox
MsgBox "Page(" & I & ") has " & N & " TextBoxes"
N = 0
Next I

End Sub

Sincerely,
Leith Ross


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
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
Excel spin box - no Control tab in Format Control dialong box tocoau Excel Worksheet Functions 7 August 10th 08 03:15 PM
Control disappeared problem - specifically, the Calendar Control JMMach[_2_] Excel Programming 0 December 16th 05 01:53 AM
Programatically control picture property of Image control Brassman[_5_] Excel Programming 5 May 24th 05 09:32 PM
Calendar Control: Can't exit design mode because control can't be created Rone Excel Programming 0 May 24th 04 04:01 PM


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