forum

Home / DeveloperSection / Forums / vbs type mismatch: [string]

vbs type mismatch: [string]

marcel ethan277020-Jun-2013
Hi,

I have the following code giving me an error and I can't understand why.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDir = objFSO.GetFolder(strOrigDir)
Set colFiles = objDir.Files

For Each strFile in colFiles
Select Case Right(strFile,3)
    Case "rar"
        strTarFile = strFile
        intIsRar = 1
        Exit For
    Case "avi" or "mkv" or "mp4"
        strTarFile = strFile
        Exit For
    Case Else
        WScript.Quit
End Select
Next

I receive the message Type mismatch: '[string:"avi"]' on the Select Case line and I can't understand why. I have checked the value of strFile using VarType to make sure I'm not going crazy and trying to compare a string to something I shouldn't be (VarType returns 8). Any ideas why this is incorrect?

Thanks in advance for any recommendations or solutions.


Updated on 20-Jun-2013

Can you answer this question?


Answer

1 Answers

Liked By