例:sub k
       form1.sho
   end sub
如何通过字符串"k"去执行k的过程

解决方案 »

  1.   

    本帖最后由 bcrun 于 2010-12-14 09:58:28 编辑
      

  2.   

    CallByName Me, "k", VbMethod
      

  3.   

    可考虑
    microsoft sctript control 1.0
      

  4.   

    本帖最后由 bcrun 于 2010-12-14 09:58:15 编辑
      

  5.   

    你是不是想要VFP的&代换那样?
      

  6.   

    动态执行方面的实现,VB本身没解释执行的功能,一般大体上就是楼上诸位提到的CallByName和microsoft sctript control 1.0
    两种方法。当然这两者都是有一定局限性的,如果你是想象JS这种动态语言那样eval一样,就不太现实了。
      

  7.   

    callbyname
    必须是类模块不知道前几天的那个什么comHelper可不可以用标准模块代替类模块 给callbyname 使用
      

  8.   

    使用microsoft sctript control 控件,或者你自己写解释器 。
      

  9.   

    sctript control 不能执行vb函数,有没有更好的思路呢?
      

  10.   

    还有一个问题:能不能获取sql server 表的主关键字段名的名称吗?
      

  11.   

    这是查询所有索引的。select object_name(t0.object_id) as table_name,
    col_name(t2.object_id,t2.column_id) as column_name,
    t0.is_unique,t0.type_desc,t0.name
    from sys.indexes t0
    inner join sys.index_columns t2 on t0.object_id = t2.object_id and t0.index_id = t2.index_id
    inner join sys.tables t3 on t0.object_id = t3.object_id
    order by table_name
    这是查询所有列信息的。
    select table_name,column_name,col_type from (
    select distinct object_name(t0.object_id) as table_name,
    col_name(t0.object_id,column_id) as column_name, 
    t2.name as col_type
    from sys.tables t0
    inner join sys.all_columns t1 on t0.object_id = t1.object_id
    left join sys.types t2 on t1.system_type_id = t2.system_type_id
    ) t
    order by table_name
     自己参照上面的修改吧,不麻烦。