Results 1 to 15 of 15

Thread: [RESOLVED] Backing Up VB6 Source Code and All

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Resolved [RESOLVED] Backing Up VB6 Source Code and All

    I'm sure this question may seem quite basic. However, I recently experienced something that caught me off-guard and I cannot take any more chances.

    I have a large single-developer project I've spent years on. I copied my VB6 project files (folder and all) to new folders on different drives in order to back them up.

    Recently I wanted to make some changes to the code and when I tried to open the project, errors of missing files and such popped up. No worries, I have backups!

    But then I found my backups were causing me grief as well. Because I just copied the files onto other drives, apparently some of the Vb6 config files have path names specifically listed. Since I copied the files to other drives, the paths no longer match.

    In the end, it turned out that what I thought were copies were simply references to files on other drives, etc. A real mess! I lost my most recent changes that took me forever to make and now I'm having to code it all in again just to get the code to work exactly like the compiled code shipped out, before adding any new features, etc.

    Now that I've spent hours/days getting most of it done, I need to know HOW to do a proper backup of my VB6 files so that no matter where I store it, it won't require having to be in the original development directory. Who knows, I may one day no longer have a Drive E where my development code currently resides. If I restore to Drive D instead, where do I make all the path changes? Or how do I restore to any drive without having to be concerned about the original path?

    Hope I am making sense. I need to secure this code so that I don't screw it up again.

    TIA

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Backing Up VB6 Source Code and All

    The best way IMO to handle VB files is to create a folder for your project. All source files for that project should either be in that folder or one of its sub folders. The paths stored will be in relative form and this allows you to move the project at will with no problems at all. If any of your source files are in a folder that is not the source folder or child thereof then the full path is stored in the vbp file and will be an issue if you try to move the project to a different location.

    I currently have well over 100 projects that have been moved to different PCs, different drives, different paths and even onto different network servers and there is never any issues to open any of these projects from any pc provided of course that PC has the required reference files installed and registered properly.

    If you have an existing project and the files are stored in other folders outside the main project folder then you can either
    1: Use save as on each form, module, class to save them to the project folder or child folder thereof
    2: Move the files manually then edit the vbp file(s) to use the relative path to the files

    What I do is create a main folder for all my code say SourceCode for example. Then in that folder I create a folder for each project.
    All source files for each project goes into that project folder or in the case of large projects a sub folder of it.
    I can easily move any or all of the projects to any path on any machine with no issues.
    This also makes backups easy as everything is located in one common location that can be easily backed up

    I took this a step farther and created a program that creates an archive of each project that has had any changes done to it, dates it and stores it on a different drive. The program scans each project for changes each night and if any change has been made to any file in a project then the entire project is added to a new archive and stored in my archives folder. I then periodically place those archives on DVDs for safe keeping just in case.

    The result of course can be a lot of copies of various projects. For example if I am working on a program every day for 4 weeks I would end up with 28 archive copies of it. I will delete some of those at some point but sometimes it can be handy to be able to go back to what you had yesterday or the day before. In any case they are all dated and only projects that change are archived so I always have a backup of every project that is no more than 24 hours prior to the last change.
    Last edited by DataMiser; Aug 4th, 2015 at 12:57 AM.

  3. #3
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Backing Up VB6 Source Code and All

    I think VB6.EXE checks a Project against its "recently used files" list when you open it. If it guesses (using some simple heuristics) that the Project has been moved it sets a dirty flag. This will then result in a prompt to "save changes" on exit even if you haven't altered a single thing.

    I believe that it does this in order to update the paths contained in the header blocks of module, designer, VBP, and VBG files to resolve the paths to the actual files and correct any paths that it can to relative paths.

    Skipping this "save, though I changed nothing" step might be one source of broken Projects. But even that should be rare unless you don't follow the Project Folder Hierarchy approach already described above.


    I stopped ever using VBG (Project Group) development many years ago. I went to strict bottom up development where dependencies are designed up front and built and tested completely independently... and I have never seen this kind of broken Project since. I think the VBG mechanism might have characteristics that can make it less bulletproof against these path changes.

  4. #4
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: Backing Up VB6 Source Code and All

    Using a version control system is the way to go, making copies for folders etc. is for... well I don't want to insult anyone but, it's not very efficient and error prone.

    I personally use http://tortoisesvn.net/ for this, but there are other systems like git, mercurial etc. but I personally prefer a centralized system like subversion (or svn for short) that tortoisesvn is a Windows client for. I know the widely spread opinions is that these tools are for "groups" that work together on code, but that's imho is a misconception. It's simply an advanced backup system that let you do more than simply keeping a backup, it also gives your development a history and I simply cannot see any serious developer being without using one.

    You can use TortoiseSVN/Subverison either strictly on your local workstation or you can have the storage part running online on a server or in your local network - your choice, but if you are serious about your programming and code, get yourself a version control system.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  5. #5
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Backing Up VB6 Source Code and All

    My experience has been that if you use "Save" in the VB IDE that sometimes -- depending on where your at (what directory / sub directory you navigated to prior to the Save) -- that the VBP file gets modified and may now contains a full path, rather than just the files names for the forms, modules, classes. Without being aware the VBP file was altered, one continues to program thinking that their current changes have been "saved" in the correct directory. At some point one may over write the actual directory where these changes occurred and then all changes are lost.

    Once I confirm that VBP file is clean -- the way I want it -- I ONLY use "Save As" NOT "Save".
    Also prior to copying - making a backup - of the directory where my VB program resides, I always look at the VBP file to ensure it has not been altered
    and if it has, I would know where to go to get my changes.

    This solved the problem you refer to for me.
    Last edited by dw85745; Aug 4th, 2015 at 09:43 AM.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Backing Up VB6 Source Code and All

    Quote Originally Posted by 7edm View Post
    Using a version control system is the way to go, making copies for folders etc. is for... well I don't want to insult anyone but, it's not very efficient and error prone..
    To each their own. All things can be prone to errors including your version control system.

    Perhaps my post was not as clear as it should have been. My program creates archives of the project if changes have been made. i.e. Zip files These are dated and contain the entire project including any sub folders that may be present. This works very well and requires no user interaction at all unless of course you need to restore a previous version of the files. I have not ran into a single issue since I started placing all project files under the same project folder, not once in 10 years so this method is only error prone if/when the user makes the error by saving the files in the wrong place.

    And yes I am a serious developer that sees no need for software such as mentioned. These make more sense when dealing with large projects and multiple developers though I have never heard of the one you mention.

  7. #7
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Backing Up VB6 Source Code and All

    Hi webbiz. I just wanted to add my support for @7edm's suggestion. No modern developer should be working without a VCS (version control system).

    I personally prefer git, but svn is a solid choice, too. Wikipedia provides a list of many more choices if you're curious. StackOverflow also has many discussions on this topic, e.g. Best Version control for lone developer?

    If your project is open-source (or if it's closed source and you don't mind spending a little money), GitHub provides an excellent introduction to VCS, and a nice Windows client to match.

    Once you get accustomed to working with VCS, you'll wonder how you ever lived without it. It's invaluable not just for backups and tracking changes, but for easy code rollbacks while debugging.

    Quote Originally Posted by DataMiser
    All things can be prone to errors including your version control system.
    [citation needed]

    I've never once experienced errors with a version control system. Can you give an example of this?
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Backing Up VB6 Source Code and All

    Well subversion is probably the most popular one that exists, and there are several forms of it in the wild.

    There are pros and cons for each approach though. I've seen some nasty disasters come from version control system failures. They're spiffy until something goes wrong and then it often goes very, very wrong. It tends to get far worse if you have multiple developers and large projects, which is why you need to keep archived copies of your repository database.

    I wouldn't worry about it. "Using source control is the One True Way" is one of those crowdsourced memes that is "safe" to parrot smugly.

    I'm not saying you shouldn't use a tool like SVN, but I sure wouldn't try beating people over the head about it.

  9. #9
    Fanatic Member
    Join Date
    Aug 2013
    Posts
    806

    Re: Backing Up VB6 Source Code and All

    Quote Originally Posted by dilettante View Post
    I'm not saying you shouldn't use a tool like SVN, but I sure wouldn't try beating people over the head about it.
    VCS ultimately makes coding much easier.

    I guess there are stubborn developers who insist on doing things the hard way, but other than laziness, I don't know why a developer would go out of their way to avoid VCS. It exists to help developers, not hurt them.

    The only people I've ever met who advise against VCS are those who haven't used them. That number seems to be less and less these days, though, since most companies won't hire developers without basic skills like VCS experience (as well they shouldn't).
    Check out PhotoDemon, a pro-grade photo editor written completely in VB6. (Full source available at GitHub.)

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Backing Up VB6 Source Code and All

    *sigh*

    Religious fanatics!

    In any case, if you want to just play around and explore the concept there are several source control systems out there which are light and portable. By this I mean they do not require much configuration for basic use, don't install any Windows Services or put anything into the registry, and in general are easy to "install" (little more than XCopy and then maybe adding to the PATH environment variable and perhaps setting up a shortcut). "Uninstall" is thus just as easy.

    Fossil is one of these.
    Last edited by dilettante; Aug 4th, 2015 at 10:33 AM.

  11. #11
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: Backing Up VB6 Source Code and All

    Quote Originally Posted by dilettante View Post
    *sigh*

    Religious fanatics!
    Not sure who or what you aim at, if any/thing/some, but I used have my own "home grown well thought out" backup copy system and while it may work for some... well, it takes some time and effort to grasp the way a VCS works and understand how to use it the best way, but ones you have invested that effort and time it will payback thousand worth. And as I said earlier, that VCS isn't for lone developers is nonsense and I agree with @Tanner_H about which ones who generally has objections to VCS. I haven't had one corruption with svn/tortoisesvn over 10+ years, but it has saved me some many times when VB6 suddenly decides it has had enough and trash my form etc.

    It's also great when you were sitting up late coding, or suddenly got an ide when coming home from a party... and next morning you quite cannot remember what you have been coding... you can see all changes with just a mouse click... it's just a matter to choose the tool that fits you best. I know SVN isn't the hip trend these days, but it's dead stable and upgrade between versions have always been stable and works very well for the lone developer, also when you have several project, sub projects that's reused in several project etc. it's very flexible and powerful. The key, as I see it from many years experience, is to commit often, to branch out even for small code jobs, and document your code. I find it crucial.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

  12. #12
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Backing Up VB6 Source Code and All

    I move projects all the time from one folder to another, from one PC to another. Why is it I never have any problems and I don't use anything except drag-n-drop


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  13. #13
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Backing Up VB6 Source Code and All

    Quote Originally Posted by jmsrickland View Post
    I move projects all the time from one folder to another, from one PC to another. Why is it I never have any problems and I don't use anything except drag-n-drop
    You won't have any problems so long as you make sure that all the project files for any given project are in the same project folder or one of its sub folders.

    Two reasons for backups the most important of which is if you loose your storage device or the files on it become corrupted. The second is that you can revert back to a previous version if needed for any reason.
    I have used many different methods over the years. At one point I thought I would be clever and create a shared folder where some files that were used in multiple projects would go. This of course turned out to be a pain and had to be abandoned as project would end up with references to files that were not in the project folder and if the project was moved then the shared folder and the files within had to be moved and the folders created under the same folder with the same name as they were originally else there would be loading issues.

    I ended up creating those shared files as templates so when I create a new project that uses one or more of them it simply makes a copy and saves it in the main project folder.

    I have worked on a few projects that used source safe. It seems to work just fine but can't say I really liked it much and definitely see no need for it in my case.

  14. #14

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Re: Backing Up VB6 Source Code and All

    Thanks for all your suggestions. It seem like a version control is definitely the way to go. Also, I guess I need to be careful when moving folders or saving. I have multiple folders and now I'm confused as to which is what as the date modified of the files change just in copying as so are unreliable. Also found some of my modules of one folder were actually being modified in another. Arrrr!

    I'll check out those version control apps and hopefully can get up to speed on one quickly.


  15. #15
    Addicted Member
    Join Date
    Jun 2010
    Posts
    182

    Re: [RESOLVED] Backing Up VB6 Source Code and All

    If you go for Subversion and the TortoiseSVN Windows client, then there is a full free online book http://svnbook.red-bean.com/ and while you can host and run this all on your workstation, I would still suggest to use an online repository for various reasons. Let's say you work from a notebook, and it gets stolen, or your house burns down... you may lose you current work copy and the latest changes, unless you committed them the last thing you did last time you coded, and as long as you haven't lost your password to the repo server, you just have to checkout a new wc from another computer and continue to work - possibly change the password if the nb got stolen.

    I can only vouch for SVN which I have used for over 10 years, it's rock solid, logical and puts you in control whether you want to work alone or later decide to interact/invite others. It's easy to learn but of course you need to give it some study and thought as there is not just one way to layout your vcs system. GIT is popular and favoured by many but I think it's better suited when cooperating with others but I really don't have much experience of it. I tried to check it out a few times and/but just like SVN (short for Subversion) it's very command line oriented but lacked a feature-rich and stable GUI client at the time. This may have changed today but "The turtle" has been around for ages and is developed by very knowledgeable guys with close links to svn and is a very powerful Windows client to work with your actual svn repo (repo is a common abbreviation used for repository, which basically is the database were all your files and associated data is stored). You wont go wrong with Subversion and TortoiseSVN but there are of course also other good alternatives.
    M$ vs. VB6 = The biggest betrayal and strategic mistake of the century!?

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