Hi, all Does somebody know how to open text file with half of its name using vb6. example i have 2 files in C:\, they are : 1. Myfile10001.txt 2. Myfile20001.txt I want to read file no.2 with 7 characters first (Myfile2xxxx.txt), and ignore next characters. my script is : Option Explicit dim file1, file2, astrx astrx = "*" file1 ="c:\Myfile10001.txt" file2 ="c:\Myfile2" & astrx & ".txt" 'this is run Sub OpenTextFile1 Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs1, f1 Set fs1 = CreateObject("Scripting.FileSystemObject") Set f1 = fs1.OpenTextFile(file1, ForReading,TristateFalse) f1.Close End Sub 'this is error Sub OpenTextFile2 Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs2, f2 Set fs2 = CreateObject("Scripting.FileSystemObject") Set f2 = fs2.OpenTextFile(file2, ForReading,TristateFalse) f2.Close End Sub
|