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

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

问题描述

社区,我目前在我的用户窗体多页上隐藏我的标签,但当前标签除外.用户可以单击按钮在页面之间来回切换.一些按钮共享子程序.当用户单击按钮时,一旦选择了新选项卡,它就会隐藏前一个选项卡.我想这是一个双重问题.

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  

推荐答案

可以使用tab change事件来判断tab什么时候改变,并将当前tabindex存储为变量.那么当tab再次改变时,这个变量中的tab就变成了之前的tab.

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天全站免登陆