Hi,
I am in the process of writing code that does the following:
1. reads text file and counts the number of pipe characters (|) present. (Each pipe in this file represents the end of a record)
2. as the code reads the text, it compares ID #'s after each pipe to see if they have changed. If so, the code prints to output the new ID #.
What I am stuck on right now is that along with counting the TOTAL number of records (which I've already successfully coded), I also need to count the number of records that have the same ID #. In other words, have a separate counter that adds one until the ID # after a pipe changes. Here is the code I have now to count the pipes and print the different ID's:
Pipecnt = 0
For Counter = 1 To Len(FileString)
If Asc(Mid(FileString, Counter, Len(FileString))) = 124 Then
sContractName = Mid(FileString, Counter, 17)
ContractName = Mid(sContractName, 14, 2)
SiteName = Mid(sContractName, 16, 2)
If SiteName <> StrSiteName Then
Debug.Print ContractName & SiteName
Call PContractName
End If
StrSiteName = SiteName
Pipecnt = Pipecnt + 1
End If
Next
Any suggestions would be GREATLY appreciated! Thanks!
I am in the process of writing code that does the following:
1. reads text file and counts the number of pipe characters (|) present. (Each pipe in this file represents the end of a record)
2. as the code reads the text, it compares ID #'s after each pipe to see if they have changed. If so, the code prints to output the new ID #.
What I am stuck on right now is that along with counting the TOTAL number of records (which I've already successfully coded), I also need to count the number of records that have the same ID #. In other words, have a separate counter that adds one until the ID # after a pipe changes. Here is the code I have now to count the pipes and print the different ID's:
Pipecnt = 0
For Counter = 1 To Len(FileString)
If Asc(Mid(FileString, Counter, Len(FileString))) = 124 Then
sContractName = Mid(FileString, Counter, 17)
ContractName = Mid(sContractName, 14, 2)
SiteName = Mid(sContractName, 16, 2)
If SiteName <> StrSiteName Then
Debug.Print ContractName & SiteName
Call PContractName
End If
StrSiteName = SiteName
Pipecnt = Pipecnt + 1
End If
Next
Any suggestions would be GREATLY appreciated! Thanks!