Pass values from Form to UserControl
Hello,
I m facing a problem in passing value from a Form to the UserControl. My project is a ActiveX Project that contains the following:
1. Form
2. UserControl
The UserControl contains a TextBox and a Command button. In clicking the command button, the Form appears.
The Form contains a ListBox and a command button. When the user selects an item from the list, and clicks the command button, the selected item should appear in the textbox of the UserControl.
I have tried creating an object of the UserControl in the Form but the failed to get any of the UserControls properties.
Please HELP!!1
Re: Pass values from Form to UserControl
You have to create the properties of the UserControl yourself. This code, for example, adds a Text property to the user control. When it's changed, the text in Text1 gets the new value. When it's retrieved, the property returns the text in Text1. :)
VB Code:
Public Property Get Text() As String
Text = Text1.Text
End Property
Public Property Let Text(ByVal NewValue As String)
Text1.Text = NewValue
PropertyChanged Text
End Property
Re: Pass values from Form to UserControl
Oh, and I didn't even notice, but you posted this in the wrong section. The VB Codebank is meant to share completed snippets of code. To ask questions, post in Classic Visual Basic. :)
Re: Pass values from Form to UserControl
Welcome to the forums.
I have moved your thread from the CodeBank to the more appropriate COM/Active X forum section.
Thank you for your participation. :)