CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  VB >  基础类

如何得到一个对象中所有过程、属性、方法名的的字符串?

楼主SonicOne(用心猫)2004-02-01 11:47:29 在 VB / 基础类 提问

如:  
   
  如题,有什么方法?xiexie 问题点数:30、回复次数:3Top

1 楼rainstormmaster(暴风雨 v2.0)回复于 2004-02-01 13:33:29 得分 30

用TypeLib   Information(工程   引用   选择并加载peLib   Information)  
   
  用法参考:  
  http://www.vb-helper.com/howto_get_property_information.html  
  详细情况请查询MSDNTop

2 楼SonicOne(用心猫)回复于 2004-02-01 21:27:26 得分 0

Title   Get   information   about   all   of   a   control's   properties    
  Keywords   control   property,   property   information,   TypeLib    
  Categories   Controls,   Software   Engineering    
     
     
     
  Thanks   to   Oigres   P.    
  Set   a   project   reference   to   the   TypeLib   Information   library.   Create   a   TLIApplication   object   and   get   an   InterfaceInfo   object   for   the   control   from   its   InterfaceInfoFromObject   function.   Then   iterate   through   the   interface's   members.    
     
     
     
  Private   Sub   Command1_Click()  
          ''caution   crashes   if   you   try   to   read   the   Form1  
          '   properties  
          iterateMembers   Text1  
  End   Sub  
   
  Sub   iterateMembers(obj   As   Object)  
          'iterate   the   members   in   the   textbox   interface  
          'put   them   in   a   flexgrid   for   viewing  
          Dim   TLI   As   New   TLIApplication,   ret   As   Variant  
          Dim   interface   As   InterfaceInfo  
          Dim   member   As   MemberInfo  
   
          On   Error   Resume   Next  
          Set   interface   =   TLI.InterfaceInfoFromObject(obj)  
          Dim   index   As   Long,   tempstr   As   String  
          ReDim   str(interface.Members.Count)   As   String  
   
          index   =   0  
          For   Each   member   In   interface.Members  
                  tempstr   =   ""  
                  tempstr   =   tempstr   &   member.Name   &   vbTab   &   _  
                          member.VTableOffset   &   vbTab   &   _  
                          Hex$(member.MemberId)   &   _  
                                  vbTab   &   member.HelpString  
                  'get   property   value;   using   memberID   is   faster   than  
                  '   member.Name  
                  ret   =   TLI.InvokeHook(Text1,   member.MemberId,   _  
                          INVOKE_PROPERTYGET)  
                  'adjust   long   values;   convert   to   hex   (else   shows   neg  
                  '   value)  
                  If   TypeName(ret)   =   "Long"   Then  
                          ret   =   "&H"   &   Hex(ret)   &   "&"  
                          tempstr   =   tempstr   &   vbTab   &   ret   &   vbTab   &   "long"  
                  Else  
                          tempstr   =   tempstr   &   vbTab   &   ret   &   vbTab   &   _  
                                  TypeName(ret)  
                  End   If  
                  'store   row   data   in   array  
                  str(index)   =   tempstr  
                  index   =   index   +   1  
   
          Next  
   
          Set   TLI   =   Nothing  
          fillGrid   str()  
  End   Sub  
     
  Top

3 楼SonicOne(用心猫)回复于 2004-02-01 21:27:53 得分 0

万分感谢,我追加10分Top

相关问题

  • 能否用字符串访问类的属性 方法
  • 把字符串转换为一个对象用什么方法??
  • 如何使用字符串实现对对象属性的修改???????????????????????
  • 如何能将字符串类型的控件名转换成控件对象,调用属性?
  • 如何能将字符串类型的控件名转换成控件对象,调用属性?
  • 请问在RDS对象中怎么写出oracle的连接字符串connect与server属性
  • 字符串类型的属性问题
  • 如何递归遍历某一对象的所有属性(包括可展开属性的子属性),并以字符串形式返回?
  • 用什么方法,可以把一个String型的字符串赋给JTextField对象?谢谢!
  • 如何把利用DataSet的GetXml()方法获得的字符串再转成DataSet对象??

关键词

  • interfaceinfo
  • iteratemembers
  • tliapplication
  • typelib
  • 方法
  • member
  • control
  • properties
  • interface
  • dim

得分解答快速导航

  • 帖主:SonicOne
  • rainstormmaster

相关链接

  • Visual Basic类图书
  • Visual Basic类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo