Problems with usercontrols

Problems with usercontrols

Post by SK » Mon, 29 Aug 2005 15:32:50

Hello everybody,

I don't know what am I doing wrong, by the message box, when I test
usercontrol in IE browser is empty.

Here is the code:


Option Explicit

Dim TextVariable As String

Event Click()
Event KeyPress(KeyAscii As Integer)

Private Sub Command1_Click()
MsgBox (TextVariable)
RaiseEvent Click
End Sub

Private Sub Command1_KeyPress(KeyAscii As Integer)
RaiseEvent KeyPress(KeyAscii)
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
TextVariable = PropBag.ReadProperty("Text", "There is no message")
End Sub

Private Sub usercontrol_resize()
Command1.Width = UserControl.Width
Command1.Height = UserControl.Height
End Sub

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

Public Property Let Text(ByVal New_Text As String)
TextVariable = New_Text
PropertyChanged "Text"
End Property

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text", TextVariable, "There is no
End Sub


Thank you,


Problems with usercontrols

Post by GreenEy » Mon, 29 Aug 2005 22:07:17

You have not set Text property. So this is empty. Add new EXE project,
set it as startup. Set Text property and click on usercontrol.

Alternatively you can set Text property to some default value. Add this

Private Sub UserControl_Initialize()
TextVariable = "Default value"
End Sub

Hope it would help you.