Chinaunix首页 | 论坛 | 博客
  • 博客访问: 188562
  • 博文数量: 106
  • 博客积分: 3810
  • 博客等级: 中校
  • 技术积分: 1007
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-18 13:35
文章分类

全部博文(106)

文章存档

2014年(17)

2011年(5)

2010年(75)

2009年(9)

我的朋友

分类:

2009-12-15 13:43:56

判断一个对象的具体类型的函数。
 

Public Function ClsName(Obj As Object) As String
    If TypeOf Obj Is Form Then ClsName = "Form": Exit Function
    If TypeOf Obj Is Frame Then ClsName = "Frame": Exit Function
    If TypeOf Obj Is PictureBox Then ClsName = "PictureBox": Exit Function
    
    If TypeOf Obj Is CheckBox Then ClsName = "CheckBox": Exit Function
    If TypeOf Obj Is ComboBox Then ClsName = "ComboBox": Exit Function
    If TypeOf Obj Is CommandButton Then ClsName = "CommandButton": Exit Function
    If TypeOf Obj Is Data Then ClsName = "Data": Exit Function
    If TypeOf Obj Is DirListBox Then ClsName = "DirListBox": Exit Function
    If TypeOf Obj Is DriveListBox Then ClsName = "DriveListBox": Exit Function
    If TypeOf Obj Is FileListBox Then ClsName = "FileListBox": Exit Function
    If TypeOf Obj Is HScrollBar Then ClsName = "HScrollBar": Exit Function
    If TypeOf Obj Is Image Then ClsName = "Image": Exit Function
    If TypeOf Obj Is Label Then ClsName = "Label": Exit Function
    If TypeOf Obj Is Licenses Then ClsName = "Licenses": Exit Function
    If TypeOf Obj Is Line Then ClsName = "Line": Exit Function
    If TypeOf Obj Is ListBox Then ClsName = "ListBox": Exit Function
    If TypeOf Obj Is MDIForm Then ClsName = "MDIForm": Exit Function
    If TypeOf Obj Is OLE Then ClsName = "OLE": Exit Function
    If TypeOf Obj Is OptionButton Then ClsName = "OptionButton": Exit Function
    If TypeOf Obj Is PropertyPage Then ClsName = "PropertyPage": Exit Function
    If TypeOf Obj Is Shape Then ClsName = "Shape": Exit Function
    If TypeOf Obj Is TextBox Then ClsName = "TextBox": Exit Function
    If TypeOf Obj Is Timer Then ClsName = "Timer": Exit Function
    If TypeOf Obj Is UserControl Then ClsName = "UserControl": Exit Function
    If TypeOf Obj Is UserDocument Then ClsName = "UserDocument": Exit Function
    If TypeOf Obj Is VBControlExtender Then ClsName = "VBControlExtender": Exit Function
    If TypeOf Obj Is VScrollBar Then ClsName = "VScrollBar": Exit Function
    ClsName = "非内部控件"
End Function

发到VBgood,又做了一些修改。


 

Public Function ClsName(Obj As Object) As String
    If TypeOf Obj Is Form Then ClsName = "Form": Exit Function
    If TypeOf Obj Is PropertyPage Then ClsName = "PropertyPage": Exit Function
   If TypeOf Obj Is UserControl Then ClsName = "UserControl": Exit Function
    If TypeOf Obj Is UserDocument Then ClsName = "UserDocument": Exit Function
    If TypeOf Obj Is VBControlExtender Then ClsName = "VBControlExtender": Exit Function
   ClsName = TypeName(Obj)
End Function

下面这个没测试。
阅读(414) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~