Results 1 to 4 of 4

Thread: Pass values from Form to UserControl

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    6

    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

  2. #2
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    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:
    1. Public Property Get Text() As String
    2. Text = Text1.Text
    3. End Property
    4.  
    5. Public Property Let Text(ByVal NewValue As String)
    6. Text1.Text = NewValue
    7. PropertyChanged Text
    8. End Property
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  3. #3
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    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.
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width