如何使用EVAL()获取Object属性? [英] How to get Object property using EVAL()?
本文介绍了如何使用EVAL()获取Object属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你能想出如何在Access2002 / VBA中做到这一点吗?
我想得到一个对象属性的值。诀窍是要检索的属性的名称存储在一个表中。
这就是我设置它的方式:
我有一个类模块objPerson它有一个属性FirstName。
这个有效:
展开 | 选择 | Wrap | 行号
解决方案
您好。我要做的是使用表中的值激活Select Case语句中的一段代码;
展开 | 选择 | Wrap | 行号
谢谢,Willakawill。这是一个可行的选择。
唯一的缺点是必须在SELECT-CASE语句中对字段进行硬编码。理想情况下,更新字符串键列表和替换文本可通过表格维护。
对于该属性,这应该有效:
dim arr
arr = split(rs!Replace_with,"。")
select case arr(0)
Case" objTenant"
strX = objTenant.properties(arr(1))
案例......等等......
Split将使用两个部分填充一个数组(基于零!),arr(0)将保存对象并且arr(1)属性。
获得想法?
Nic; o)
Can you figure out how to do this in Access2002/VBA?
I want to get the value of an object property. The trick is that the name of the property to retrieve is stored in a table.
Here''s how I''ve set it up:
I have a class module "objPerson" which has a property "FirstName".
This works:
Expand|Select|Wrap|Line Numbers解决方案Hi. What I would do is use the value in the table to activate a section of code in a Select Case statement;
Expand|Select|Wrap|Line Numbers
Thank you, Willakawill. That is a workable alternative.
The only disadvantage is that the fields would have to be hardcoded in the SELECT-CASE statement. Ideally, updating the list of string Keys and the Replacement text would be maintainable via a table.
For just the property this should work:
dim arr
arr = split(rs!Replace_with,".")
select case arr(0)
Case "objTenant"
strX = objTenant.properties(arr(1))
Case .... etc ...
The Split will fill an array (zero based!) with the two parts and arr(0) will hold the object and arr(1) the property.
Getting the idea ?
Nic;o)
这篇关于如何使用EVAL()获取Object属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆