This Select statement parses to the CASE ELSE statement EVERY TIME. Even though the IF..THENs parse correctly, the SELECT CASE does not.
I have added msgbox and temorary IF..THENs to verify that the values of sFileName are what I expect.
They are.
Any ideas. Wits end has been reached.
'========================================
Dim oFileSystem As Object
Dim oFiles As Object
Dim oSub As Object
Dim sFileName As String
Dim sFullName As String
Dim iFileSize As Integer
icount = icount + 1
Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oFiles = oFileSystem.GetFolder(sDirPath)
For Each oSub In oFiles.Files
sFileName = oSub.name
sFullName = sDirPath & "" & oSub.name
lFileSize = oSub.Size
' Temporary statements to examine and verify sFileName
If Right(" " & sFileName, 4) = ".txt" Then MsgBox ".txt"
If InStr(sFileName, "shs_extract") > 0 Then MsgBox "What the? shs_extract"
If IsNumeric(Left(sFileName, 5)) And Right(" " & sFileName, 4) = ".xml" Then MsgBox "What the? Number and XML"
If iFileSize > 0 Then MsgBox "what the? zero size"
Select Case sFileName
'===================================================
Case Right(" " & sFileName, 4) = ".txt"
' ignore the file as it cannot be a valid QDC submission.
MsgBox ".txt file"
'===================================================
Case InStr(sFileName, "shs_extract") > 0
' If the file name contains the string 'shs_extract' then move
' it to the SHS folder.
Filetodie = sFullName
Name sFullName As sHomelessDir & sFileName & "." & Left(sFileName, 5)
Call KillFile(Filetodie)
MsgBox "Homeless file"
'===================================================
Case IsNumeric(Left(sFileName, 5)) And Right(" " & sFileName, 4) = ".xml"
' If the file name begins with a five digit number and is an xml file, it needs to be
' checked against the table to see if it is valid and that it is active.
' REMOVED PROCESSING THINGS HERE.
Case Else
MsgBox "Exception"
' NOT AN EASILY PROCESSED FILE. PUT IT IN THE UNACCEPTABLE SUBMISSION FOLDER
Filetodie = sFullName
Name sFullName As sIssuesDir & sFileName & ".Exception"
Call KillFile(Filetodie)
End Select
Next oSub
Set oFiles = Nothing
Set oFileSystem = Nothing