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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem using "Like" in DTS ActiveX VB Script

Status
Not open for further replies.

GJP55

Technical User
Feb 2, 2003
220
0
0
GB
Is there are problem using the "Like" operator in VB Script Language in a DTS ActiveX Script ?

I get an error description of sub or function not defined when I run the code below but if I use
[If oFile.Name = "MainReferral99.csv" Then] instead then the code runs ok.


Function Main()
Dim oFSO
Dim sDirectoryPath
Dim oFolder
Dim oFileCollection
Dim oFile

Set oFSO = CreateObject("Scripting.FileSystemObject")
sDirectoryPath = "S:\ThamesProcessing\"
Set oFolder = oFSO.GetFolder(sDirectoryPath)
Set oFileCollection = oFolder.Files

For Each oFile In oFileCollection

If oFile.Name like "*Referral*.csv" Then
MsgBox oFile.Name
' oFile.Delete (True)
End If

Next

Set oFSO = Nothing
Set oFolder = Nothing
Set oFileCollection = Nothing
Set oFile = Nothing

Main = DTSTaskExecResult_Success

End Function
 
Excellent, exactly what I was after.
Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top