Skip to content

Commit f63899d

Browse files
committed
Update CSVinterface.cls
1 parent 249b0ed commit f63899d

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

src/CSVinterface.cls

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ Attribute GetRecordIndex.VB_Description = "Returns the Index in wich the record
583583
Do While hpointer = 0& 'Escape char may be on subsequent Index
584584
CSVdataArray(index) = vbNullString
585585
index = index + 1&
586-
LenCurrentIndex = LenB(CSVdataArray(index))
586+
If index <= MaxIndex Then LenCurrentIndex = LenB(CSVdataArray(index))
587587
SearchBeginningMark = 1
588588
hpointer = InStrB(SearchBeginningMark, CSVdataArray(index), EscapeChr) 'Find escape char
589589
Loop
@@ -627,7 +627,7 @@ Attribute GetRecordIndex.VB_Description = "Returns the Index in wich the record
627627
SplittedToken = False 'Restart Token status
628628
CSVdataArray(index) = vbNullString
629629
index = index + 1&
630-
LenCurrentIndex = LenB(CSVdataArray(index))
630+
If index <= MaxIndex Then LenCurrentIndex = LenB(CSVdataArray(index))
631631
OverStringPointer = 1&
632632
Else
633633
SearchBeginningMark = OverStringPointer
@@ -650,7 +650,7 @@ Attribute GetRecordIndex.VB_Description = "Returns the Index in wich the record
650650
RecordEndReached = True
651651
CSVdataArray(index) = vbNullString
652652
index = index + 1&
653-
LenCurrentIndex = LenB(CSVdataArray(index))
653+
If index <= MaxIndex Then LenCurrentIndex = LenB(CSVdataArray(index))
654654
OverStringPointer = 1&
655655
End If
656656
End If
@@ -659,6 +659,7 @@ Attribute GetRecordIndex.VB_Description = "Returns the Index in wich the record
659659
'@----------------------------------------------------------------------------
660660
'Skip lines if needed
661661
SkipUnwantedLines index, MaxIndex, CSVdataArray
662+
If index <= MaxIndex Then LenCurrentIndex = LenB(CSVdataArray(index))
662663
Loop
663664
If index <= MaxIndex Then
664665
GetRecordIndex = index
@@ -1390,6 +1391,7 @@ Attribute ParseCriticalCSV.VB_Description = "Parses text strings CSV
13901391
'@----------------------------------------------------------------------------
13911392
'Skip lines if needed
13921393
SkipUnwantedLines index, MaxIndex, tmpCSV
1394+
LenCurrentIndex = LenB(tmpCSV(index))
13931395
'@----------------------------------------------------------------------------
13941396
'Loop through tmpCSV array
13951397
Do While (index <= MaxIndex And RecordsCount < ImportDepth)
@@ -1843,15 +1845,28 @@ Attribute SkipUnwantedLines.VB_Description = "Ignores empty, blanks and commente
18431845
Else
18441846
'@----------------------------------------------
18451847
'Ignore non printable chars at the string start
1846-
Do While CharCode >= 0& And CharCode <= 32& And StrPointer < CurLength
1847-
StrPointer = StrPointer + 2&
1848-
If StrPointer > CurLength Then 'Non printable line
1849-
UnwantedLine = True
1850-
Exit Do
1851-
End If
1852-
CharCode = AscW(MidB$(Arr(Idx), StrPointer, 2))
1853-
Loop
1854-
If CharCode = P_COMMENTSTOKEN Then UnwantedLine = True
1848+
Select Case P_ASCW_FIELDS_DELIMITER
1849+
Case Is <> 9
1850+
Do While CharCode >= 0& And CharCode <= 32& And StrPointer < CurLength
1851+
StrPointer = StrPointer + 2&
1852+
If StrPointer > CurLength Then 'Non printable line
1853+
UnwantedLine = True
1854+
Exit Do
1855+
End If
1856+
CharCode = AscW(MidB$(Arr(Idx), StrPointer, 2))
1857+
Loop
1858+
If CharCode = P_COMMENTSTOKEN Then UnwantedLine = True
1859+
Case Else
1860+
Do While (CharCode >= 0& And CharCode <= 32&) And (StrPointer < CurLength And CharCode <> 9)
1861+
StrPointer = StrPointer + 2&
1862+
If StrPointer > CurLength Then 'Non printable line
1863+
UnwantedLine = True
1864+
Exit Do
1865+
End If
1866+
CharCode = AscW(MidB$(Arr(Idx), StrPointer, 2))
1867+
Loop
1868+
If CharCode = P_COMMENTSTOKEN Then UnwantedLine = True
1869+
End Select
18551870
End If
18561871
End If
18571872
If UnwantedLine Then

0 commit comments

Comments
 (0)