View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default accesing controls in for each loop

I suggest you don't use a For Each loop but a For i = x to y type instead:

Dim i As Integer
With MultiPage1.Pages(0)
'Index value of 1st control is 0 and last control is .Controls.Count - 1
For i = 1 To .Controls.Count - 1
MsgBox .Controls(i).Text & vbCr & .Controls(i - 1).Text
Next
'Alternate:
'For i = 2 To .Controls.Count
'MsgBox .Controls("TextBox" & i).Text & vbCr & .Controls("TextBox" & i -
1).Text
'Next
End With

Regards,
Greg Wilson

"Gixxer_J_97" wrote:

hi all!

when you are using something like:

for each o in multipage1.pages(0).controls

next

o is the current control being 'looked' at out of the X number of controls
on multipage1.pages(0)

my question is - how do you access the previous control? ie so you could
compare the contents of the previous text box with the present text box.

tia!

J