0

Few my control are subclassed for getting better overal result of my programs. Those subclases inherits from original NET controls. I have it under my Toolbox in VB.NET ide. Assuming I uses it in Project1 Form designer places it in form like so:

    Me.btn_OK = New Project1.xButton()

After that I create one new project: Project2 and add those subclasses like files "as a link" into those new project. In order to getting it to work I have do delete "Project1." from its name. When I compile that project new definiton appears:

    Me.btn_OK = New Project2.xButton()

This also works good but no more for Project1 where I have to delete "Project2." again to get it work.

Is here something I can do that VB.NET may leave such assignment:

    Me.btn_OK = New xButton()

what will let me to use same subclass file in both (or more) projects? Any other related advice will be welcome.

5
  • You can store them in a sort of Library folder, then to use them in another project, add an item using the Add as Link. Not sure if that is what you are asking Dec 27, 2017 at 20:05
  • I do such way but every project add his name to those controls what makes it unusable for other projects,
    – Wine Too
    Dec 27, 2017 at 20:31
  • Not sure what you mean. If you import the Class File for the control (not project) as a Link, you will have to import that Namespace. Retrofitting can be a pain, but if designed to be used that way from the start, there is no problem and they are completely (re)usable. Dec 27, 2017 at 20:42
  • Except I am far away from start :) What to do now to avoid automatic import of namespaces?
    – Wine Too
    Dec 28, 2017 at 8:56
  • What can I say? Measure twice, cut once. If it is a control, develop it in its own solution with the control in one project and another project to test it. You can give the control the namespace you want in code. Then just include the class in other projects as needed. it isnt that hard to resolve namespace changes - add an import statement and then accept changes the IDE suggests. Dec 28, 2017 at 16:31

1 Answer 1

0

You need to make a new project, select Visual Basic Class Library. Add your classes to this project, and then reference the new project in Project1 and Project2.

Microsoft Tutorial

2
  • That way I will produce a dll file what is not wanted. One more thing to worry about in work (debug/release) and in deploying too. I hope some other, more VB basic way exists.
    – Wine Too
    Dec 27, 2017 at 20:29
  • @WineToo, One more thing to worry about in work - "one big thing" vs "multiple small thing".
    – Fabio
    Dec 28, 2017 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.