Delete A File - Snippet


Below is a very small VB6 code snippet. It allows you to delete a file from the hard drive. To try out this Visual Basic code snippet first go to your hard drive and create a new text file on the C drive. Call the file test.txt and fill it with some junk data. Now create a new Visual Basic program. On the main form add a command button. Double click the command button to get to the click event code. Add the following inside the click event handler

  1. Dim Filename As String
  2. Dim Answer
  3. Filename = "C:\Test.txt"
  4. Answer = MsgBox("Are you sure you want to delete " & Filename, vbYesNo)
  5. If Answer = vbYes Then
  6.     Kill Filename
  7. End If

Obviously in a real world application you would not hard code in the file name but for simplicity sake we did so here. They key to getting rid of the file is the Kill Filename command. This is left over from the old original dos days but it still works today.

This was a very basic example to give you a taste of what VB6 allows you to do in relation to File handling. We also have a whole list of VB6 File Handling Tutorials located on this site. Feel free to check them out to learn much more about dealing with files in VB.

Note: The source for this was found at DreamVB which is no longer online.

If you enjoyed this post, subscribe for updates (it's free)

red bottom shoes

In accordance to a trusted source, this marketplace, in particular, is predicted to acquire by the robust fourteen percent by 2016 The online world offers access louis vuitton outlet to many buyers that may be searching for your company from many different regions due to the fact that the internet allows for christian louboutin shoes outlet international interest The basic theme and music of these ringtones varies from 1 a further You will find no circumstances that make it michael kors bags worth doing When you're in the presentation for a bank or you should thoroughly list all of the assets that will be purchased michael kors outlet online using loan proceeds Different people and groups consume different products and introduction of certain items can pose as an insult to them People louis vuitton store feel overwhelmed and don't know where to startThe affordability of solar energy is another problem that any solar company will emphasize persistent MA Louis Vuitton Sale But, sticking with the basics is usually the simplest way to achieve it When it "sees" you coming, these devices actually turns on gucci outlet the garage lights automaticallyArticles on your blog or other websites and blogs act like permanent links generate continuous traffic as long as they louis vuitton outlet online stay on that location The benefit of getting a gold bullion coin is the fact that, When purchasing gold coins, it could be louis vuitton purses advantageous and helpful to make certain they're bold bullion coins because they have specific guarantees that you'll want if you are utilizing them louis vuitton handbags for investment purposes Different types of tools and equipment used in chemical laboratories and physicians Very often people call a repair sewer Van michael kors Nuys most things involving the toilets and water appliancesThe first thing you ought to be aware of is where all of this pollution michael kors outlet is coming from and in most cases it's coming from our vehicles, power plants and any other types of fuel we burn That's Christian Louboutin outlet online because, the least favoured method was to contact supporters via a personal welcome call? ABC Window Company resides in Ontario, Canada? Barber and Ross Co louis vuitton store You can have the best gadgets around, but it won't matter if there are no people who are able to use it properly gucci outlet online When it became apparent that working as a muffler salesman will not pave the louis vuitton bags way to his dreams, he moonlighted in online business The beneficial thing dealing with these online suppliers is that you can take vantage of the certainty that you can order a general product contingent on the magnitude of dough you will be capable louis vuitton bags to spend for it Then we would politely suggest they have not read Dante, or experienced If you know these languages, you can louis vuitton outlet online modify the templates with none difficulties Eye popping banners are vibrant owing to the quality of the paper which is compatible with a michael kors outlet large variety of dyes and inks that are used to create or etch the final impressions on the paperSubscribe to their newsletters and Authentic Louis Vuitton Handbags you can discover a few of their multilevel marketing secrets0 sites

you should try this Kill

you should try this

Kill "(filename+extension)"

example : Kill "vb6.exe"

hope that thing works

I always wrap my Kill

I always wrap my Kill commands in on "error resume next / on error goto 0" blocks. There's always the chance the file may get deleted before your kill command can execute.

There is another one....

There is another one.... It's more simple than this code.

I thought it was Kill

I thought it was Kill "filename" right?

Delete A File - Snippet

I try this code but there's an error..

Kill Filename is that a command?? because when i try the code above the Kill Filename is error

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.