开发者

construct a string and use it to call a variable

This is probably a dumb question but I have to call one of 30 or so global variables by constructing the variable name to be called from another information. However when i do that it treats it as a string. Any ideas on how to make this work?

eg something like this:

Public gsNewYork As String

public sub Getinfo

dim lslocation as string
dim a as string = "New"
di开发者_运维问答m b as string = "York"

lslocation = "gs" + a + b
lblLabel.text = lslocation

Any ideas on how to construct the variable name and have it identified as the variable name?


The most common solution to this problem is to store your variables in a Dictionary, where the strings you build are the key.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜