Results 1 to 8 of 8

Thread: [RESOLVED] Replacing an existing form with an improved version

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    62

    Resolved [RESOLVED] Replacing an existing form with an improved version

    I have an existing, working application written in VB with just a couple of forms. One of the forms is rather complex (about 530 controls) and it's time to improve the usability of the form by changing the visual layout of the controls. With my limited experience with Visual Studio, I don't know the best way to accomplish this without destroying the original form. In a perfect world, here are some things I could do:

    1. Simply clone the existing project and make all the changes in the new project, thus preserving the original. I see that many people over the years have asked about cloning a project in this way, but isn't easily done because of filenames and other considerations.

    2. In the existing project, create a new form with all the modifications. Then rename the original form to some name indicating it's a backup and then renaming the new form using the name of the original form. What I don't know is: are there other linkages unknown to me that would prevent this approach from working.

    Are there other ways to accomplish what I need to do? I've probably overlooked other simple solutions due to inexperience with lots of Visual Studio projects.

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: Replacing an existing form with an improved version

    You can create a Github repository for the Visual Studio solution. Once done create a new branch intended changes.

    Master branch is the original, secondary branch is for moving forward.

    https://help.github.com/en/github/co...our-repository

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    62

    Re: Replacing an existing form with an improved version

    Thanks for the suggestion. At this point, I know NOTHING about GIT Hub and would prefer a way to do this within Visual Studio.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,302

    Re: Replacing an existing form with an improved version

    Your suggested option 1 is easy. You simply make a copy of the root folder, i.e. the folder containing the solution file. The SLN file contains the paths of project files but they are relative, so there's no issue. If people have trouble doing this it's because they did something silly.

    That said, using source control would be the best way and offer other benefits too. You could always learn something about Github, like everyone else who uses it has.

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,990

    Re: Replacing an existing form with an improved version

    Your second option should work. At worst, make a backup of the project before you try that final step of renaming. Still, it should work as long as the publicly visible, and used, properties and methods match (if the property or method isn't used, it doesn't matter whether or not it matches). After all, a form is just a class. If you have Class Foo with some few methods, then create a Class Bar with the same few methods, that is much like a form class, except that it lacks that visible element (which is still just code found in the .designer.vb file for the form). Swapping one for the other can be done just as you described.

    Of course, if there is a constructor for the form that takes arguments, then the new form must have the same constructor, or if some other object expects the form to have property P, then the new form must have property P. Fortunately, if you get something like that wrong, you'll know about it right away, as it will produce a compile time error, so you can rite what you didn't write right, right?
    My usual boring signature: Nothing

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,467

    Re: Replacing an existing form with an improved version

    Quote Originally Posted by Shaggy Hiker View Post
    Your second option should work. At worst, make a backup of the project before you try that final step of renaming. Still, it should work as long as the publicly visible, and used, properties and methods match (if the property or method isn't used, it doesn't matter whether or not it matches). After all, a form is just a class. If you have Class Foo with some few methods, then create a Class Bar with the same few methods, that is much like a form class, except that it lacks that visible element (which is still just code found in the .designer.vb file for the form). Swapping one for the other can be done just as you described.

    Of course, if there is a constructor for the form that takes arguments, then the new form must have the same constructor, or if some other object expects the form to have property P, then the new form must have property P. Fortunately, if you get something like that wrong, you'll know about it right away, as it will produce a compile time error, so you can rite what you didn't write right, right?
    Wright

  7. #7
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,684

    Re: Replacing an existing form with an improved version

    Quote Originally Posted by Solo44 View Post
    Thanks for the suggestion. At this point, I know NOTHING about GIT Hub and would prefer a way to do this within Visual Studio.
    Those who use GitHub now when they started knew nothing either. Also, Visual Studio online is another option which works in Visual Studio too or even run Visual Studio from the cloud.

    Here is a screenshot inside Visual Studio using GitHub.
    Name:  2019-12-08_4-59-32.jpg
Views: 100
Size:  56.3 KB

    On a side note, the image above can be found on the Visual Basic .NET landing page for Microsoft documentation which I'm a contributor.

    https://docs.microsoft.com/en-us/dot...ZDO7EBGNjXjfu0
    Name:  111111.jpg
Views: 95
Size:  64.6 KB

  8. #8

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    62

    Re: Replacing an existing form with an improved version

    OK - When I get some spare time, I'll dig into Git Hub. For now, here's the solution I arrived at:

    1. Create a template of the existing application

    2. Create a new application using that template (new name of course)

    3. Create the new version of the main form for the new application

    4. In Project - Properties - Application, change the startup form to the name of the new version of the main form.

    Given that this is a hobby-related application, I'm satisfied with that approach. Thanks for all the input.

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