"Complex" Object as A Class

  • 15 years ago

    I have a very complicated input form which I need to reproduce as many times as the user needs. I see using classes as an ideal solution but haven't grasped how.


    I have a frame (which is a job card input frame) on the form which contains numerous textboxes, dropdown combo boxes and labels (many of which are in arrays as they are repeated).


    As the user needs an additional jobcard I would like to add an exact duplicate of the frame (with all the textboxes, labels, etc) to the current form when a command button is clicked.


    Set jobcardX = New classJobCard ?


    How do I define the details of the entire frame in a class so I can duplicate it?


  • 15 years ago

    Bradley


    You can achieve this by designing your own ActiveX control.


    As you have grasped the fundamentals of classes, this is just an extension of the principles.


    Post back if you require further details


    Trevor

  • 15 years ago

    I tried creating a user control of the frame with all the additional controls on it.


    I could load as many of these usercontrols as I wanted using the load method.
    But I couldn't access the individual control details within the usercontrol. I was expecting something like


    Code:
    myuserCtrl(index ).combo1.text


    Would the activeX be different?
    I presume I create the activeX in a similar way as the usercontrol.
    But load it as a class? Then each instance would operate independantly. Still how do I extract details from the "onboard" standard controls like the combo1 example above?

  • 15 years ago

    We are at slightly crossed lines, ActiveX Control and UserControl are the same thing.


    In brief, to access the value of the textbox you can expose specific properties as required.


    For example:

    Code:
    Public Property Let TextBoxValue(ByVal UserText As String)


    UserControl.Text1.Text = UserText


    End Property


    Public Property Get TextBoxValue()As String


    TextBoxValue = UserControl.Text1.Text


    End Property



    Then in your Main application

    Code:

    myUserCtrl(Index).TextBoxValue = "Whatever you want to assign"


    strText = myUserCtrl(Index).TextBoxValue



    Hope this helps


    Trevor

  • 15 years ago

    Thanks TrevorG,


    Almost had it last night but gave up.
    What you have indicated makes sense. Once again thanks for the help.


    What I did notice and was going to be a question today was the difference between usercontrol and an actoveX control. As you said they are the same. The only difference I could see was that a control created as a USER CONTROL in a project is housed within that project and only usable in that project. A control created as an ACTIVEX 'stand-alone' control is kind of independent and can be slotted into any project.


    Their behaviour within the projects is identical though.


    Is this correct?

  • 15 years ago
    Bradley,

    You are essentially correct .
    If you create an ActiveX Control project, the result is a .OCX file that can be used in any project.

    Once compiled the OCX is available to VB via Project - Components (like adding a WinSock control to a project).

    For further information check out MSDN - Exposing Properties of Constituent Controls

    Trevor

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debuggers don't remove bugs. They only show them in slow motion.”