Reputation: 1044
The following code was written in vbscript and I'm in the process of converting over to visual basic.
On the following line: If Right(LCase(oFile.Name), 3) = "pdf" Then
I get the following error: Variable 'Right' is used before it has been assigned a value. A null reference exception could result at runtime. Also is says Object variable or With block variable not set.
To my best of knowledge, I believe it is checking to make sure the filenames right 3 characters are "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
Upvotes: 0
Views: 412
Reputation: 3111
You need to put:
Imports Microsoft.VisualBasic
at the beginning of your program. "Right" is a function in this namespace.
http://msdn.microsoft.com/en-us/library/dxs6hz0a(v=vs.80).aspx
Upvotes: 1