VB6 Small Backup Program

Darkness1337's Avatar author of VB6 Small Backup Program
This is an article on VB6 Small Backup Program in Visual Basic [VB].
Been away for long time so just decided to make a little tutorial about file handling, I'll make it a clear as possible however if it's not clear then just pm me

Background



Little tutorial about file handling this is something that i did for my course work...

In this tutorial i will tell u how to make a small back up program to back up a text document some of you may already know this but hope this will help someone*

lets go step by step!

get ready :

1. open VB
2. New project [don't do anything, yet]
3. Save the project in a folder [make a folder on your desktop name it "backup_program"and save it there for easy access]
4. make a folder there [name it "original"]
5. make another folder [name it "backup]



Screenshot above shows what it should look lyk after you create them folders...

6. rite, now you need a text file in this example i am using "example.txt", thats the file we going to back up]

7. open notepad and type in some random stuff and then save it in the "original" folder.



8. open the VB project you just saved lets get down to making our superb interface!



thats what it should look like!

two command buttons

1
name : cmdCheck
caption : CheckForTheFile
2
name : cmdBackUp
caption : BackupFile

9. now double click on the CheckForFile command button to start coding there are many ways to check if the files there... i am going to use DIR$

so,

first declare a variable
Dim FileCheck as string

and then you can use that variable to check the file availability

basically you telling the program to look in "original" directory for the file called "example.txt"

FileCheck = Dir$("original/example.txt")

and then if the file is not there, FileCheck value will be blank! if it is there then the FileCheck value will be equal to file name... therefore if the file is there the value of FileCheck will be equal to "example.txt"

we could could use that to check if the files present!

to do that we could make a IF statement

Code: VB
if FileCheck = "example.txt" then
    msgbox "File Found"
else
    msgbox "File Not Found"
end if
or we could say:

Code: VB
if FileCheck <> "" then
    msgbox "File Found"
else
    msgbox "File Not Found"
end if
either of them will work,,...

now check if it works...

if you get the message box saying "File Found" then your good to go...

...............

now we could get down to coding our second button :BackUpFile: get to the code window

now we know the file is there so we could make the backup now.. here we are using FileCopy method to copy the file to the "backup" directory

simple:

when you type in FileCopy VB will tell you what you have to type in there!

FileCopy "original/example.txt", "backup/exampleBackUp.txt"

right on here we could add date so we know what date that files been backed up all you have to do is put Date$ in middle

FileCopy "original/example.txt", "backup/exampleBackUp" Date$ ".txt"

The code



A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips.

Blocks of code should be set as style "Formatted" like this.
Code: VB
Private Sub cmdBackUp_Click()
    FileCopy "original/example.txt", "backup/example" & Date$ & ".txt"
    MsgBox "Backup Complete!!"
End Sub

Private Sub cmdCheck_Click()
    Dim FileCheck As String
    FileCheck = Dir$("original/example.txt")
    If FileCheck <> "" Then
        MsgBox "File Found"
    Else
        MsgBox "File Not Found"
    End If
End Sub
thats what the code look like



there is our backed up file

hope that helped!!!

References



http://www.vbexplorer.com/VBExplorer...00/may2000.asp
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Nomination for article of the month of May
Dak914's Avatar, Join Date: May 2008
Go4Expert Member
Two things:
1) Yeah, So much for the whole "I dont care about article of the month"!
2) Why would you bash me when you have a whole lot more you could be doing. Obviously, you know what you are talking about with VB programs. It isnt all that hard to see.
3) (extra message) I see that the whole slang language is just a one-time-lazy type thing.
I hate being bashed, and, since we both know what we are talking about, why not be fair to each other.
Well that is all I have to say.
~3xistanc3
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by Dak914
Two things:
1) Yeah, So much for the whole "I dont care about article of the month"!
2) Why would you bash me when you have a whole lot more you could be doing. Obviously, you know what you are talking about with VB programs. It isnt all that hard to see.
3) (extra message) I see that the whole slang language is just a one-time-lazy type thing.
I hate being bashed, and, since we both know what we are talking about, why not be fair to each other.
Well that is all I have to say.
~3xistanc3
Can you quote the reference of your post
Darkness1337's Avatar, Join Date: Mar 2007
Ambitious contributor
waeva u say!

go bak to watching diehard4.0...
lolz

http://www.go4expert.com/showthread....7&page=2&pp=10

Last edited by Darkness1337; 13Jun2008 at 07:45..
Dak914's Avatar, Join Date: May 2008
Go4Expert Member
The referrence is "Change the admin password the easy way..." I posted a while back.
MartinJose's Avatar, Join Date: Aug 2010
Contributor
It's a easy and useful tool. I wiill go and make one.
Full Zip Hoody's Avatar, Join Date: Sep 2010
Go4Expert Member
i just managed to do a small back up program which can back up a text document using your method above, thanks for the tut darkness
mukeshsoftona's Avatar
Banned
Hi dear.

i never heard about it. This is very informative post.

Last edited by mukeshsoftona; 11Nov2011 at 17:32..
edwardallene's Avatar, Join Date: Apr 2012
Go4Expert Member
I have a short course of VB in our school and learning this program makes me more knowledgeable somehow because when I have my interface and then one thing that I should do is to run the program. I haven't tried to back up my file using VB, your post is very informative and it is very useful. I would love to try this and save my file to this software. Hope you will post again about what you have learn in VB.