I am using the below function to read a text file which has below format. I need to lookup the id (column1) and return date (column2). I cannot understand what is wrong with my code. So my code runs perfectly till readline, but some how it is not looping. So basically it just checks the incoming consumerSSN with only the first SSN from the txt file. So if I pass getDOH(213396391), it retuns blank(""), instead of its corresponding date.
sraDOH.txt:
578171533,2015-01-01 00:00:00
213396391,2015-06-01 00:00:00
077966385,2015-01-01 00:00:00
216418521,2015-01-01 00:00:00
Function getDOH(consumerSSN)
dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
dim doh, t, x
For Each File In fso.GetFolder(fso.GetAbsolutePathName("..\Test Files\")).Files
If File.Name = "sraDOH.txt" Then
Set tsIn2 = fso.OpenTextFile(File, 1)
Do While Not tsIn2.AtEndOfStream
doh = tsIn2.ReadLine
t = split(doh,",")
If consumerSSN = t(0) Then
getDOH = t(1)
Else
getDOH = ""
End If
Loop
End If
Next
End Function
Aucun commentaire:
Enregistrer un commentaire