VB 2010 - 带有标签名称值的变量 [英] VB 2010 - A variable with a value of a label name

查看:27
本文介绍了VB 2010 - 带有标签名称值的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 VB 2010 Express,并且在我的表单中有一个名为lblTitle"的标签.下一个代码不起作用,我知道,但我该怎么做?

I'm using VB 2010 Express and have a label named "lblTitle" in my form. The next code doesn't work and I know it , but how can I do something like this?

Dim bla As String
bla = "lblTitle"
bla.Text = "Hello world"

我想访问标签属性而不实际使用它的名称.我从一个文本文件中得到它的名字.

I want to access a label properties without actually having its name. I get its name from a text file.

编辑 2:谢谢大家!在谷歌搜索你提到的这个功能后,我得到了它:

Edit 2: Thanks you all guys! After googling this function you've mentioned I got it:

   Dim bla = "lblName"
   Me.Controls(bla).Text = "Dan"

虽然lblName"是表单中的标签名称.

While "lblName" is a label's name in the form.

推荐答案

经过谷歌深度搜索,答案似乎很简单:

After a deep google search , the answer seems to be easy as that:

   Dim bla = "lblName"
   Me.Controls(bla).Text = "Dan"

lblName 是表单中的标签名称.谢谢各位

while lblName is the label's name in the form. Thanks guys

这篇关于VB 2010 - 带有标签名称值的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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