简体   繁体   English

从字符串 (VBA) 中引用 Excel 用户窗体控件名称值

[英]Referencing Excel Userform Control Name Value From String (VBA)

Typically when referencing a userform control value in Excel VBA I would enter something to the effect of radiobutton.value通常在 Excel VBA 中引用用户窗体控件值时,我会输入一些影响 radiobutton.value 的内容

However, I want to be able to use a string as the name of the user control.但是,我希望能够使用字符串作为用户控件的名称。 The idea behind this would be to dynamically be able to generate the control name and reference a value from it.这背后的想法是能够动态地生成控件名称并从中引用一个值。

For example I may want to reference ctradiobutton.value one time, and etradiobutton.value the next, these controls already exist on the form, I just want to reference a different name of the control from a string created on the current iteration.例如,我可能想引用 ctradiobutton.value 一次,然后引用 eradiobutton.value,这些控件已经存在于表单中,我只想引用与当前迭代中创建的字符串不同的控件名称。

像这样( Me是用户窗体)

Me.Controls("TextBox1").Value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM