设为首页收藏本站

八达网

 找回密码
 注册
查看: 140|回复: 1
打印 上一主题 下一主题

哥火星老?vb居然有这么个强大函数

[复制链接]

372

主题

1

好友

3万

积分

大和

我自横刀向天笑,笑完我就去睡觉.睡醒我就拿起刀,再次横刀向天

战队
Linyu)
联赛ID
[ReD]NaDa
种族
Terran
跳转到指定楼层
1
发表于 2008-4-25 13:26 |只看该作者 |倒序浏览
http://msdn2.microsoft.com/zh-cn/library/chsc1tx6(VS.80).aspx


Visual Basic 语言参考
CallByName 函数
执行对象的方法,或者设置或返回对象的属性。


Public Function CallByName( _   ByVal ObjectRef As System.Object, _   ByVal ProcName As String, _   ByVal UseCallType As CallType, _   ByVal Args() As Object _) As Object

参数ObjectRef 必选。Object。指向公开属性或方法的对象的指针。
ProcName 必选。String。包含对象的属性名或方法名的字符串表达式。
UseCallType 必选。CallType 枚举类型的枚举成员,表示所调用过程的类型。CallType 的值可以是 MethodGetSet
Args 可选。ParamArray。参数数组,包含要传递给所调用的属性和方法的参数。
异常

异常类型 错误号 条件
ArgumentException
5
无效 UseCallType 值;必须为 MethodGetSet

如果正在升级使用无结构错误处理的 Visual Basic 6.0 应用程序,请参见“错误号”一列。(您可以根据 Number 属性(Err 对象)比较错误号。)然而,如果可能,应当考虑用 Visual Basic 的结构化异常处理概述替换这种错误控制。



备注
CallByName 函数在运行时用来获取属性,设置属性或调用方法。



示例
在下面的示例中,第一行使用 CallByName 设置文本框的 Text 属性,第二行检索 Text 属性的值,第三行调用 Move 方法以移动文本框。
Visual Basic
复制代码

' Imports statements must be at the top of a module.Imports Microsoft.VisualBasic.CallType
Visual Basic
复制代码

Sub TestCallByName1()    'Set a property.    CallByName(TextBox1, "Text", CallType.Set, "New Text")    'Retrieve the value of a property.    MsgBox(CallByName(TextBox1, "Text", CallType.Get))    'Call a method.    CallByName(TextBox1, "Hide", CallType.Method)End Sub
下一个示例使用 CallByName 函数调用集合对象的 AddItem 方法。
Visual Basic
复制代码

Public Sub TestCallByName2()    Dim col As New Collection()    'Store the string "Item One" in a collection by     'calling the Add method.    CallByName(col, "Add", CallType.Method, "Item One")    'Retrieve the first entry from the collection using the     'Item property and display it using MsgBox().    MsgBox(CallByName(col, "Item", CallType.Get, 1))End Sub



智能设备开发人员说明
不支持此函数。



要求
命名空间: Microsoft.VisualBasic
模块: Interaction
程序集: Visual Basic Runtime Library(在 Microsoft.VisualBasic.dll 中)



请参见
参考CallType 枚举
ArgumentException Class
概念参数数组
使用字符串名调用属性或方法

780

主题

0

好友

13万

积分

主区版主

Rank: 8Rank: 8Rank: 8Rank: 8

2
发表于 2008-4-25 13:53 |只看该作者
什么意思?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

手机版|Archiver|八达网    

GMT+8, 2026-1-26 20:21

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部