动态获取字符串值vb.net [英] get string values dynamically vb.net

查看:62
本文介绍了动态获取字符串值vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要解决方案vb.net:



公共temp1为整数

公共temp2为整数



定义标签



text1.tag =temp1

text2.tag =temp2



所以我想像text1一样编程检查其标签名称并在其文本中加载同名公共变量'的数据



喜欢



temp1 = 30.5

temp2 = 31.6





动态



text1.text = 30.5因为text1.tag =temp1

text2.text = 31.6因为text2.tag =temp2



所以要理解

need solution vb.net:

Public temp1 as integer
Public temp2 as integer

define tag

text1.tag= "temp1"
text2.tag= "temp2"

so I want to program like text1 check its tag name and load same name public variable''s data in its text

like

temp1=30.5
temp2=31.6


so dynamically

text1.text=30.5 because text1.tag= "temp1"
text2.text=31.6 because text2.tag= "temp2"

so understand

推荐答案




使用字典

http://msdn.microsoft.com/en-us/library/xfhwa508.aspx [ ^ ]

Hi,

Use a Dictionary:
http://msdn.microsoft.com/en-us/library/xfhwa508.aspx[^]
Dim tagAndText As New Dictionary(Of String, Double)()
tagAndText.Add("temp1", 30.5)
tagAndText.Add("temp2", 31.6)

' and to set the text of the label:
text1.Text = tagAndText(text1.Tag)
text2.Text = tagAndText(text2.Tag)



希望这有帮助。


Hope this helps.


这篇关于动态获取字符串值vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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