以下代码是用 vbscript 编写的,我正在转换为 Visual Basic。
在以下行中:If Right(LCase(oFile.Name), 3) = "pdf" Then
我收到以下错误:在为其赋值之前使用了变量“Right”。运行时可能会导致空引用异常。也是说对象变量或未设置块变量。
据我所知,我相信它正在检查以确保文件名正确的 3 个字符是“pdf”?
For Each oFile In oFolder.Files
If Right(LCase(oFile.Name), 3) = "pdf" Then
Data = Replace(oFile.name, ".pdf", "")
Data = Replace(oFile.name, ".PDF", "")
Data = Split(Data, "-")
acct = Data(1)
lob = Data(2)
fileName = clientid & "-" & acct & "-" & lob & "-" & speciesid & "-" & seq & ".pdf"
outputLine = acct & "," & speciesid & "," & lob & "," & oFile.Name & "," & inputDate
oOutFile.WriteLine(outputLine)
End If
Next