初学控件碰到问题! 我按照msdn上的控件编程一步一步做下来,可是添加了代码Caption = Extender.Name后,运行时就出现了错误!请问这是为什么,错误提示是不支持此对象! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 caption 是个属性名!这个已经定义了! 全部代码如下:Private Sub UserControl_Initialize()Debug.Print "Initialize"End SubPrivate Sub UserControl_InitProperties()'将 ShapeLabel 实例的名字'赋给 Caption 属性'作为它的初始值。Caption = Extender.NameDebug.Print "InitProperties"End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)Debug.Print "ReadProperties"Caption = PropBag.ReadProperty("Caption", _Extender.Name)End SubPrivate Sub UserControl_Resize()' 变换 Shape 控件的大小' 以便填充 ShapeLabel 的可见表面。shpBack.Move 0, 0, ScaleWidth, ScaleHeight' 使 Label 控件垂直居中,' 并使它的宽度与 ShapeLabel 一致。lblCaption.Move 0, (ScaleHeight _- lblCaption.Height) / 2, ScaleWidthEnd SubPrivate Sub UserControl_Terminate()Debug.Print "Terminate"End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)Debug.Print "WriteProperties"PropBag.WriteProperty "Caption", Caption, _Extender.NameEnd SubPublic Property Get Caption() As StringCaption = lblCaption.CaptionEnd PropertyPublic Property Let Caption(ByVal NewCaption As String)lblCaption.Caption = NewCaptionPropertyChanged "Caption"End Property Private Sub UserControl_Initialize()Debug.Print "Initialize"End SubPrivate Sub UserControl_InitProperties()'将 ShapeLabel 实例的名字'赋给 Caption 属性'作为它的初始值。Caption = Extender.NameDebug.Print "InitProperties"End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)Debug.Print "ReadProperties"Caption = PropBag.ReadProperty("Caption", _Extender.Name)End SubPrivate Sub UserControl_Resize()' 变换 Shape 控件的大小' 以便填充 ShapeLabel 的可见表面。shpBack.Move 0, 0, ScaleWidth, ScaleHeight' 使 Label 控件垂直居中,' 并使它的宽度与 ShapeLabel 一致。lblCaption.Move 0, (ScaleHeight _- lblCaption.Height) / 2, ScaleWidthEnd SubPrivate Sub UserControl_Terminate()Debug.Print "Terminate"End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)Debug.Print "WriteProperties"PropBag.WriteProperty "Caption", Caption, _Extender.NameEnd SubPublic Property Get Caption() As StringCaption = lblCaption.CaptionEnd PropertyPublic Property Let Caption(ByVal NewCaption As String)lblCaption.Caption = NewCaptionPropertyChanged "Caption"End Property 按着你的代码我建了工程,在Usercontrol对象上加了一个Label控件,命名为lblCaption,加了一个Shape控件,命名为shpBack,然后将一个实例放至在窗体上,运行工程,没有错误啊。lblCaption.Caption是控件的名称啊。 我知道是什么问题了,是因为我每次运行程序时,程序就会自动打开ie,然后显示控件?为什么我不能直接运行我的那个testform呢?这是为什么呢?就是因为这个原因才出的问题! 把TestCtlDemo这个工程设为启动 各位大哥请请帮帮小弟!我加载一个data控件类,所报出来的错误小弟查了好多资料没法解决,请帮帮忙!!!!! vb群6537626 才57个人. 大家加啊.不是我创的,是上面的网友 treeview相关,难啊!就没有人会吗? 高手请进:VB操作excel问题,数据源是email的正文! IC卡程序开发(有源码) 请介绍一些VB的安装工具 救命啊~~~~~~~~~急急~!!!!!!!! 如何在一个程序已启动时,避免启动它的第二个实例? 哇哇哇,这里是分给完了问题就到完成区的吗???? 哪有vb运行库? 求开机代码或控件(不过可在加分) 如何使这段宏让所有的客户端都调用?
Private Sub UserControl_Initialize()
Debug.Print "Initialize"End SubPrivate Sub UserControl_InitProperties()
'将 ShapeLabel 实例的名字
'赋给 Caption 属性
'作为它的初始值。
Caption = Extender.NameDebug.Print "InitProperties"End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Debug.Print "ReadProperties"
Caption = PropBag.ReadProperty("Caption", _
Extender.Name)
End SubPrivate Sub UserControl_Resize()' 变换 Shape 控件的大小
' 以便填充 ShapeLabel 的可见表面。
shpBack.Move 0, 0, ScaleWidth, ScaleHeight
' 使 Label 控件垂直居中,
' 并使它的宽度与 ShapeLabel 一致。
lblCaption.Move 0, (ScaleHeight _
- lblCaption.Height) / 2, ScaleWidthEnd SubPrivate Sub UserControl_Terminate()
Debug.Print "Terminate"End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)
Debug.Print "WriteProperties"
PropBag.WriteProperty "Caption", Caption, _
Extender.Name
End SubPublic Property Get Caption() As String
Caption = lblCaption.CaptionEnd PropertyPublic Property Let Caption(ByVal NewCaption As String)
lblCaption.Caption = NewCaption
PropertyChanged "Caption"End Property
Debug.Print "Initialize"End SubPrivate Sub UserControl_InitProperties()
'将 ShapeLabel 实例的名字
'赋给 Caption 属性
'作为它的初始值。
Caption = Extender.NameDebug.Print "InitProperties"End SubPrivate Sub UserControl_ReadProperties(PropBag As PropertyBag)
Debug.Print "ReadProperties"
Caption = PropBag.ReadProperty("Caption", _
Extender.Name)
End SubPrivate Sub UserControl_Resize()' 变换 Shape 控件的大小
' 以便填充 ShapeLabel 的可见表面。
shpBack.Move 0, 0, ScaleWidth, ScaleHeight
' 使 Label 控件垂直居中,
' 并使它的宽度与 ShapeLabel 一致。
lblCaption.Move 0, (ScaleHeight _
- lblCaption.Height) / 2, ScaleWidthEnd SubPrivate Sub UserControl_Terminate()
Debug.Print "Terminate"End SubPrivate Sub UserControl_WriteProperties(PropBag As PropertyBag)
Debug.Print "WriteProperties"
PropBag.WriteProperty "Caption", Caption, _
Extender.Name
End SubPublic Property Get Caption() As String
Caption = lblCaption.CaptionEnd PropertyPublic Property Let Caption(ByVal NewCaption As String)
lblCaption.Caption = NewCaption
PropertyChanged "Caption"End Property
lblCaption.Caption是控件的名称啊。