Results 1 to 2 of 2

Thread: reading flat file by first 3 characters of the falt file name???

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    4

    reading flat file by first 3 characters of the falt file name???

    --------------------------------------------------------------------------------

    PRESENTLY I AM READING A FLAT FILE BY THE FOLLOWING CODE

    lstrFileName = App.Path & "\abcd.ini"

    NOW I GOT A NEW REQUIREMENT WHERE IN I HAVE TO READ FLAT FILE IN THE DIRECTORY IF THE FIRST 4 CHARCTERS OF FLAT FILE NAME IS:

    “Abc-“

    flat file name may be "abc-xxx.txt"
    I.E IF THE FLAT FILE HAS FIRST 4 CHARCATERS AS "abc-" THEN I HAVE TO READ THE FLAT FILE IRRESPECTIVE OF NEXT 3 CHARACTERS (xxx)

    COULD ANY ONE HELP ME IN THIS?
    THANKS IN ADVANCE

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Re: reading flat file by first 3 characters of the falt file name???

    Welcome to the forum.
    You can use the dir function to look through the files in a directory
    eg
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim strPath As String
    3. Dim strFile As String
    4.     strPath = App.Path
    5.     If Left(strPath, 1) <> "\" Then strPath = strPath & "\"
    6.     strFile = Dir(strPath & "abc-*")
    7.     Do While strFile <> ""
    8.         lstrFileName = strPath & strFile
    9.         ' process the file here
    10.         strFile = Dir
    11.     Wend
    12. End Sub

    BTW Writing in all caps is considered rude in this forum, it is considered as SHOUTING.
    Frans

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