Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2007, 04:55 PM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Rafter
Default Get files with 001, 002, 003 aso. names..

Hi
I have to take data from many files with names like: filename001.txt filename002.txt filename 003.txt and so on, up to more than hundred, like filename158.txt..
I divided the filename in three parts. Part 1: "filename" Part 2:(in to three integers (n1 n2 and n3 as Integers) and Part 3: ".txt"

The first filename starts with 000, then 001 aso.. If there is a filename with 000, then EXTRACT data from it, delete the file and then check for next file(filename001.txt).. and so on..
If there is NO filename000.txt then stop.

But please help me to make the code for doing this in a smart/easy way.
I use VB Express 2005, and the streamReader to open files..
Thanks.
Rafter

I am a NEWBIE coder!
Rafter
 
Old March 15th, 2007, 06:20 AM
Authorized User
 
Join Date: Nov 2006
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

To accomplish your goal, you should read up on the use of the FORMAT command and "My.Computer.Filesystem". In the meantime, here is a bit of code to help:
For intX As Integer = 0 To 100
    Dim strFileName As String = "YourFileNameHere" & Format(intX, "00#") & ".Txt"
    If My.Computer.FileSystem.FileExists(strFileName) Then
        '* Do something with your file
    End If
Next intX




Best Regards,
Earl Francis





Similar Threads
Thread Thread Starter Forum Replies Last Post
Report: First and Last Names scandalous Access 4 February 12th, 2007 02:38 PM
display names of the files as links europhreak Classic ASP Basics 1 February 20th, 2006 07:09 PM
Window Names panos Javascript How-To 2 February 10th, 2006 11:33 AM
To Many Names bachuss SQL Language 0 January 18th, 2006 12:40 PM
paging 001+001=002 <> 2 gilgalbiblewheel Classic ASP Databases 1 February 15th, 2005 05:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.