菜鸟VB控件的问题
来源:百度知道 编辑:UC知道 时间:2024/06/24 23:12:18
比如说这个控件是一个验证数字串的。
当我在控件里的文本框中输入数字串,然后点控件中的按钮C1时,如果数字串正确,变量yz为true,否则为flase。
那我在调用这个程序的代码中如何取得控件中变量yz的值呢?
菜鸟菜鸟,代码详细点。谢谢。注释注释……
程序中:
sub ....
if 控件.yz=true then
....
else
....
end if
end sub
应该看得明白我的意思吧……
贴一个简单的例子,添加Text属性
Public Property Get Text() As Variant
Text = Label1.Caption
End Property
Public Property Let Text(ByVal vNewValue As Variant)
Label1.Caption = vNewValue
PropertyChanged "Text"
End Property
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Label1.Caption = PropBag.ReadProperty("Text", "")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text", Label1.Caption, "")
End Sub
主菜单->工具->添加过程
类型中选择"属性"
然后名称为你想要的属性名
这样就可以了
Public Property Get Text() As Variant
Text = Label1.Caption
End Property
Public Property Let Text(ByVal vNewValue As Variant)
Label1.Caption = vNewValue
PropertyChanged "Text"
End Property
Private Sub UserControl_ReadProperties(Pr