已经出现font属性了,但是在设置完确定时报错--错误的参数号或无效的属性赋值。Public Property Get Font() As StdFont
     Set Font = Text.Font
End PropertyPublic Property Let Font(ByVal vNewValue As StdFont)
   Set Text.Font = vNewValue
End Property是内置的1个text,应该怎么改。

解决方案 »

  1.   

    不会是Text控件数组吧!检查一下textBox的Index属性
      

  2.   

    Public Property Get Font() As Font
        Set Font = Text1.Font
    End PropertyPublic Property Set Font(ByVal New_Font As Font)
        Set Text1.Font = New_Font
        PropertyChanged "Font"
    End Property
      

  3.   

    不是,在学习做控件,将usercontrol继承text的属性。
    如上的时候报错了。
    另外MultiLine属性是只读的,不允许这样写怎么办?
    Public Property Let MultiLine(ByVal vNewValue As Boolean)
        Text.MultiLine = vNewValue
    End Property
      

  4.   

    这个就没办法了继承了。通常的解决办法有两个
    1、建立text控件数组,分别设置,然后根据需要显示不同的text。但系统占用较大。
    2、使用API动态创建textbox,不过难度较大。
      

  5.   

    '注意!不要删除或修改下列被注释的行!
    'MappingInfo=Text1,Text1,-1,Font
    Public Property Get Font() As Font
        Set Font = Text1.Font
    End PropertyPublic Property Set Font(ByVal New_Font As Font)
        Set Text1.Font = New_Font
        PropertyChanged "Font"
    End Property
      

  6.   

    我晕,感谢 lndlwwh830(笑天星) 和  leolan(史留香)  。
    我开始自己写的,以为和 leolan(史留香)一样,还是报错,以为机器出问题了
    copy了 lndlwwh830(笑天星)发现是对的,狂晕。
    仔细检查发现用的是set,而属性自己的是Let,为什么会这样?Set和Let的区别在哪?什么时候需要用到?
    还能再帮忙解答一下吗?
      

  7.   

    刚以为成功了,设计模式下都正常,但是到运行时,又回到了初值。我已经保存了Font,以下两种方法都试过!哪里出错了?
    1---   PropertyChanged "Font"2---   Dim m_Font As Font          Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
                  Font = PropBag.ReadProperty("Font", m_Font)
              End Sub          Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
                  PropBag.WriteProperty "Font", Font, m_Font
              End Sub
      

  8.   

    解决了 
    这里也要 set Font = PropBag.ReadProperty("Font", m_Font)