Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set InFile

Status
Not open for further replies.

M626

Programmer
Joined
Mar 13, 2002
Messages
299
I would like to be able to set the infile to be any of these but I get an runtime error trying to run it.

'Set The Input Text Stream
vFilePathIn = "ICVER001.ANS" Or _
"ICVER001.ANS" Or _
"ICVER002.ANS" Or _
"ICVER003.ANS" Or _
"ICVER004.ANS" Or _
"ICVER005.ANS" Or _
"ICVER006.ANS" Or _
"ICVER007.ANS" Or _
"ICVER008.ANS" Or _
"ICVER009.ANS"
If Not fsoIn.FileExists(vFilePathIn) Then
fsoIn.CreateTextFile (vFilePathIn)
End If
Set fFileIn = fsoIn.GetFile(vFilePathIn)
Set tStreamIn = fFileIn.OpenAsTextStream(ForReading, TristateFalse)
 
You vFilePathIn assignment will never work.

It looks like you are trying to make some kind of pick-list and hand to the FSO's FileExist method for evaluation. The FileExist's filespec parameter requires a string that specifically identifies one file. Wild cards are not supported, otherwise one could use "ICVER00?.ANS".

You will need to put your file list in a string array and then iterate through that array. For example:
Code:
Private Sub Command1_Click()
    Dim strList As String
    Dim sa() As String
    Dim ix As Integer
    
    strList = "ICVER001.ANS, " & _
        "ICVER001.ANS, " & _
        "ICVER002.ANS, " & _
        "ICVER003.ANS, " & _
        "ICVER004.ANS, " & _
        "ICVER005.ANS, " & _
        "ICVER006.ANS, " & _
        "ICVER007.ANS, " & _
        "ICVER008.ANS, " & _
        "ICVER009.ANS"
    sa = Split(strList, ", ")
    For ix = 0 To UBound(sa)
        Debug.Print sa(ix)
    Next ix
    Debug.Assert False
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top