How to dynamically get the value of current multipage tab value?

懵懂的女人 提交于 2019-12-01 22:50:09

You can use the tab change event to determine when the tab is changed and store the current tab index as a variable. Then when the tab is changed again, the tab in this variable becomes the previous tab.

Ie:

Private iPrevTab As Integer
Private iCurTab As Integer

Private Sub MultiPage1_Change()
    iPrevTab = iCurTab
    iCurTab = MultiPage1.Index

    'You can also check here what that tab is to do something with it
    If MultiPage1.Value = MultiPage1.Pages("mySpecialPage").Index Then
        'Go Nuts
    End If

End Sub

You can then loop through all the tabs and check against their name, caption or index. Eg:

Private Sub LoopTabs()
    Dim ii as Integer        

    for ii = 1 to MultiPage1.Pages.Count
        If MultiPage1.Pages(ii).Index = iPrevTab Then
           Debug.Print MultiPage1.Pages(ii).Name & " " & MultiPage1.Pages(ii).Caption
        End If
    Next ii
End Sub

It's probably also worth noting to be careful showing and hiding tabs as it is not common and could possibly confuse the user. I'll leave that up to you though.

Rtronic

I think that will help you.

Dim m As String
    m = MultiPage1.SelectedItem.Caption
MsgBox m
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!