需要使用存储在字符串 vb6 中的值引用变量
我正在使用 For 循环遍历一些代码。 迭代变量是“i”。 我在 For 循环之前确定了以下变量的尺寸。 L1、L2、L3、L4 作为字符串。 我想通过某种方式引用“L”和“L”来在 For 循环内引用这些字符串。 字符(i)。 就像值“Foo”的比较一样 “灯; Char(i),当 i=1 时,结果应该是针对存储在变量 L1 中的字符串测试“Foo”。 或者当 i=2 时对抗 L2 等等。
我以前的编程经验是 Visual FoxPro,我所要做的就是在前面加上 & 。 位于字符串的前面,然后引用名称存储在字符串中的变量。
因此,如果 L1 存储“Bar”,并且我想进行比较,我可以写 &L1 ==“Bar”。 我需要能够使用 VB6 来完成此操作。 有人可以帮忙吗?
I am looping through some code using a For loop. The iterative variable is "i". I have dimensioned the following variables prior to the For Loop. L1, L2, L3, L4 as strings. I want to reference these strings inside the For loop by somehow referring to "L" & char(i). So like a comparison of a value "Foo" <> "L" & Char(i), should result is testing "Foo" against the string stored in variable L1, when i=1. Or against L2 when i=2 and so on.
My previous programming experience is Visual FoxPro and all I had to do was prefix an & on the front of the string and it then referenced the variable whose name is stored in the string.
So if L1 stored "Bar", and I wanted to compare I could write &L1 == "Bar". I need to be able to do this with VB6. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我建议您创建一个数组,而不是创建 4 个变量。 前任:
Instead of creating 4 variables, I would suggest that you create an array. Ex:
你真正想要的是一个数组,如下所示:
What you really want is an array, like this:
这适用于类(例如 VB 表单):
This works in a class (e.g. a VB Form):