如何动态获取当前多页选项卡的值? [英] How to dynamically get the value of current multipage tab value?

查看:151
本文介绍了如何动态获取当前多页选项卡的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

社区,我目前正在将我的标签隐藏在我的userform multipage上,除了当前选项卡。用户可以点击按钮在页面之间来回切换。一些按钮共享子例程。当用户单击按钮时,一旦选择了新选项卡,它将隐藏上一个选项卡。我想这是一个双重问题。

Community, I am currently hiding my tabs on my userform multipage except for the current tab. The user can click buttons to switch back and forth between pages. Some buttons share sub routines. When a user clicks a button, it hides the previous tab once the new tab has been selected. I suppose this is a dual question.

1)如何获取上一个选项卡选择值?

1) How can I get the previous tab selection value?

2)如何循环浏览我的选项卡值?我的目标是测试当前的标签标题或价值对所有其他。无论哪个页面和哪个按钮都调用子程序,这将是一种隐藏它们的简单方法。

2) How can I loop through my tab values? My objective is to test the current tab caption or value against all the others. Figured this would be an easy way of hiding them all regardless as to which page and which button calls the subroutine.

现在我只有一个选项卡按钮.. 。

Right now I only have this for one tab button...

Sub NewCreditSetup()
    MultiPage1.Pages(1).Visible = True
    MultiPage1.Value = 1
    MultiPage1.Pages(0).Visible = False
    //More code displaying tab...irrelevant
End Sub  


推荐答案

您可以使用选项卡更改事件来确定选项卡何时更改,并存储当前选项卡 index 作为变量。然后当标签再次更改时,此变量中的选项卡将成为上一个选项卡。

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.

即:

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.

这篇关于如何动态获取当前多页选项卡的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆