我需要翻阅隐藏的网页。我有10个隐藏的页面,每个页面上都有很多控件。
我需要的是确定哪个页面是下一个页面,如下所示:
Dim i as Integer
For Each i In Me.MultiPage1.Pages(i)
If Me.MultiPage1.Pages.Visible = False Then
'DO STUFF HERE
End If
Next i我希望这能解释。这很简单,但是我找不到任何检查页面的循环文档。
谢谢
发布于 2017-03-19 06:32:49
如果希望保持编码版本的样式,并从0循环到Pages控件中的MultiPage1数量,则需要使用命令:Me.MultiPage1.Pages.Count获得Pages的编号。
码
Dim i As Long
For i = 0 To Me.MultiPage1.Pages.Count - 1
If Me.MultiPage1.Pages(i).Visible = False Then
MsgBox "Page index " & i & " is hidden" ' <-- message box just for testing
'DO STUFF HERE
End If
Next i编辑1
支持条例草案所作的新澄清:
Dim i As Long, j As Long
Dim LastVisPg As Long
For i = Me.MultiPage1.Pages.Count - 1 To 0 Step -1
Debug.Print MultiPage1.Pages(i).Caption
If Not Me.MultiPage1.Pages(i).Visible Then
For j = i - 1 To 0 Step -1
If Me.MultiPage1.Pages(j).Visible Then
LastVisPg = j
GoTo LastVisPageFound
End If
Next j
End If
Next i
LastVisPageFound:
MsgBox "Last Visible Page index is " & LastVisPg & ", Next unvisible page index is " & LastVisPg + 1
'=== OPTIONAL === : Set the next Page to Visible, and set the focus to it when the focus to this page
Me.MultiPage1.Pages(LastVisPg + 1).Visible = True ' unhide the next unvisible Page
Me.MultiPage1.Value = LastVisPg + 1 ' set focus to the next unvisible Page when User_Form loads发布于 2017-03-19 01:56:25
试试这个:
For Each pg In Me.MultiPage1.Pages
If pg.Visible = False Then
'Do something
End If
Next pg编辑关于第二个问题:
从上面的:.Visible = True,我将添加什么来找到最后一个.Visible = True并激活它旁边的页面。例如,如果它停在Pages(4)上,那么添加下一页(5)
添加一个变量来记住最后一个可见页面,如下所示:
Dim lastvisible As Integer
For Each pg In Me.MultiPage1.Pages
If pg.Visible = False Then
'set the varible to this page index
lastvisible = pg.index
'Do something
End If
Next pg当循环完成变量"lastvisible“将包含最后一个可见页的索引时,您现在可以使用它来设置有关该页或以下任何示例中的任何内容(将最后一个可见页旁边的页面设置为可见页):
Me.MultiPage1.Pages(lastvisible + 1).Visible = Truehttps://stackoverflow.com/questions/42880850
复制相似问题