Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,在 Visual Basic 中
Dim VariableName As String VariableName = "button1" VariableName.Visible = true
将 button1 设置为可见。
编辑:我明白了!
Me.Controls(variableName).Visible = True
好吧,VariableName 是一个字符串,而字符串没有名为“可见”的属性。
您想获得实际的 Button 本身。您可以这样做的一种方法是(未经测试):
dim btn as Button for each c in Controls if c.name = "button1" then btn = c end if next btn.visible = true
编辑:OP找到了一个更好的解决方案,尽管如果您正在寻找具有特定“文本”属性或类似内容的文本框,这可能会起作用。