问题描述
是否可以确定文本框在哪些页面上具有任何值?
并获取非空文本框选项卡的名称。
设置:
在Page1 TextBox1上,在Page2 TextBox2上。
如果TextBox2具有值初始化,则需要获取页面的名称。
预先感谢!
到目前为止,我一直在尝试从特定文本框中获取值。
a = ""
Dim r As Integer
For r = 5 To 12
If step_0.Controls("TextBox" & r).Value <> "" Then
a = a & " " & step_0.MultiPage1.Pages(r - 5).Caption
End If
Next
最后,我设法解决了这个问题。
解决方法
所以经过一番思考,我找到了这个解决方案。
如果您想将多页标题与文本框结合使用,这会很方便。
代码:
a = ""
Dim r As Integer
For r = 5 To 12
'according to count of textboxes should be 1 to whatever
If UserForm1.Controls("TextBox" & r).Value <> "" Then
a = a & " " & UserForm1.MultiPage1.Pages(r - 5).Caption
'since the first page index is 0,subtract the integer. It only works if they arranged like this:
'page0-tbox1,page1-tbox2 page_n-tbox_n+1....
'a= creates a list with the captions of pages which has fulfilled textboxes.
End If
Next