各位大哥大姐,我在设计自定义控件时?

sym1978 2003-11-10 12:09:27
我在设计自定义控件时,为自定义的textbox控件
我需要他里面有text属性,
不知怎么自定义其属性,
比如我还需要另加他有个aa属性,
不如怎么弄,是不是用属性页呀,

请各位给个例子,或别的,我为这问题,已经查了两天了
...全文
30 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
evbsky 2003-11-12
  • 打赏
  • 举报
回复
菜单->外接程序->外接程序管理器->ActiveX控件接口向导
射天狼 2003-11-12
  • 打赏
  • 举报
回复
Private Sub txtMask_Change()
ls_Text = txtMask.Text
End Sub

加上这句就行了!!
sym1978 2003-11-12
  • 打赏
  • 举报
回复
谢谢射天狼
射天狼 2003-11-11
  • 打赏
  • 举报
回复
你是怎么写的!?我这给你的可是好用的代码啊!!
把你的代码贴出来看看!!
sym1978 2003-11-11
  • 打赏
  • 举报
回复
Option Explicit

'属性初始值
Const ini_Text = "0"
Const ini_MaxLength = 0
Const ini_PointNum = 2
Const ini_SignFlag = True
Const ini_Align = 0
Const ini_Enabled=True '新加行
'属性设置值
Private ls_Text As String
Private li_MaxLength As Integer
Private li_PointNum As Integer '小数位数
Private lb_SignFlag As Boolean '是否允许输入符号
Private ll_Align As Long
Private lb_Enabled as Boolean '新加行
Private Sub UserControl_InitProperties()
Text = ini_Text
PointNum = ini_PointNum
SignFlag = ini_SignFlag
MaxLength = ini_MaxLength
Enabled=ini_Enabled ''新加行

End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
With PropBag
Text = .ReadProperty("Text", ini_Text)
PointNum = .ReadProperty("PointNum", ini_PointNum)
SignFlag = .ReadProperty("SignFlag", ini_SignFlag)
MaxLength = .ReadProperty("MaxLength", ini_MaxLength)
Align = .ReadProperty("Align", ini_Align)
enabled=.readProperty("Enabled",ini_enabled) '新加行
End With
End Sub

Public Property Get Text() As String
Text = ls_Text
End Property

Public Property Let Text(ByVal vNewValue As String)
ls_Text = vNewValue
txtMask.Text = ls_Text
UserControl.PropertyChanged "Text"
End Property

Public Property Get PointNum() As Integer
PointNum = li_PointNum
End Property

Public Property Let PointNum(ByVal vNewValue As Integer)
li_PointNum = vNewValue
UserControl.PropertyChanged "PointNum"
End Property

Public Property Get SignFlag() As Boolean
SignFlag = lb_SignFlag
End Property

Public Property Let SignFlag(ByVal vNewValue As Boolean)
lb_SignFlag = vNewValue
UserControl.PropertyChanged "SignFlag"
End Property

Public Property Get MaxLength() As Integer
MaxLength = li_MaxLength
End Property

Public Property Let MaxLength(ByVal vNewValue As Integer)
li_MaxLength = vNewValue
txtMask.MaxLength = li_MaxLength
UserControl.PropertyChanged "MaxLength"
End Property

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
With PropBag
Call .WriteProperty("Text", ls_Text, ini_Text)
Call .WriteProperty("PointNum", li_PointNum, ini_PointNum)
Call .WriteProperty("SignFlag", lb_SignFlag, ini_SignFlag)
Call .WriteProperty("MaxLength", li_MaxLength, ini_MaxLength)
Call .WriteProperty("Align", ll_Align, ini_Align)
Call .writeProperty("Enabled",lb_enabled,ini_enabled)‘新加行
End With
End Sub
'新加行开始
Public Property Get Enabled() As Boolean
Enabled= lb_Enabled
End Property

Public Property Let Enabled(ByVal vNewValue As Boolean)
lb_enabled = vNewValue
UserControl.PropertyChanged "Enabled"
End Property
'新加行结束

Public Property Get Align() As Variant
Align = ll_Align
End Property

Public Property Let Align(ByVal vNewValue As Variant)
ll_Align = Align
End Property
射天狼 2003-11-10
  • 打赏
  • 举报
回复
Option Explicit

'属性初始值
Const ini_Text = "0"
Const ini_MaxLength = 0
Const ini_PointNum = 2
Const ini_SignFlag = True
Const ini_Align = 0

'属性设置值
Private ls_Text As String
Private li_MaxLength As Integer
Private li_PointNum As Integer '小数位数
Private lb_SignFlag As Boolean '是否允许输入符号
Private ll_Align As Long

Private Sub UserControl_InitProperties()
Text = ini_Text
PointNum = ini_PointNum
SignFlag = ini_SignFlag
MaxLength = ini_MaxLength
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
With PropBag
Text = .ReadProperty("Text", ini_Text)
PointNum = .ReadProperty("PointNum", ini_PointNum)
SignFlag = .ReadProperty("SignFlag", ini_SignFlag)
MaxLength = .ReadProperty("MaxLength", ini_MaxLength)
Align = .ReadProperty("Align", ini_Align)
End With
End Sub

Public Property Get Text() As String
Text = ls_Text
End Property

Public Property Let Text(ByVal vNewValue As String)
ls_Text = vNewValue
txtMask.Text = ls_Text
UserControl.PropertyChanged "Text"
End Property

Public Property Get PointNum() As Integer
PointNum = li_PointNum
End Property

Public Property Let PointNum(ByVal vNewValue As Integer)
li_PointNum = vNewValue
UserControl.PropertyChanged "PointNum"
End Property

Public Property Get SignFlag() As Boolean
SignFlag = lb_SignFlag
End Property

Public Property Let SignFlag(ByVal vNewValue As Boolean)
lb_SignFlag = vNewValue
UserControl.PropertyChanged "SignFlag"
End Property

Public Property Get MaxLength() As Integer
MaxLength = li_MaxLength
End Property

Public Property Let MaxLength(ByVal vNewValue As Integer)
li_MaxLength = vNewValue
txtMask.MaxLength = li_MaxLength
UserControl.PropertyChanged "MaxLength"
End Property

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
With PropBag
Call .WriteProperty("Text", ls_Text, ini_Text)
Call .WriteProperty("PointNum", li_PointNum, ini_PointNum)
Call .WriteProperty("SignFlag", lb_SignFlag, ini_SignFlag)
Call .WriteProperty("MaxLength", li_MaxLength, ini_MaxLength)
Call .WriteProperty("Align", ll_Align, ini_Align)
End With
End Sub

Public Property Get Align() As Variant
Align = ll_Align
End Property

Public Property Let Align(ByVal vNewValue As Variant)
ll_Align = Align
End Property
victorycyz 2003-11-10
  • 打赏
  • 举报
回复
看一下用向导后VB给出的代码。
sym1978 2003-11-10
  • 打赏
  • 举报
回复
为何我根据射天狼的代码,
在输入给自定义控件mytb值后,
在其按键bottom 的click中运行
msgbox mytb.text
得过不到mytb中我输入的值
sym1978 2003-11-10
  • 打赏
  • 举报
回复
cuizm(射天狼
我按了例子,加入了一个Enabled的属性,怎么加到程序中不起作用呀

7,789

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧