The program I'm writing is going to parse a file and extract certain data and then sync 2 files (attention and heart rate).
here is the string causing the problem:
Look 1 (Center) -- Start Time: 0.2 sec, End Time: 2.6, Duration: 2.4 sec
Yes, the spaces in the front are standard, and there are 15, I used word and displayed hidden characters.
/edit - there ARE 15 leading spaces, it doesn't show it though...
Here is the code causing the problem:
ReDim iStartLk(1 To itrialNum, 1 To iLooks) As Single
ReDim iendlk(1 To itrialNum, 1 To iLooks) As Single
ReDim ilkdur(1 To itrialNum, 1 To iLooks) As Single
iTrialctr = 0
Do Until iRow > iBotRow
sstr = Range("A" & iRow)
If InStr(sstr, "Trial") <> 0 Then
iTrialctr = iTrialctr + 1
iLkctr = 1
End If
If InStr(sstr, "Look") <> 0 Then
iStrLen = Len(sstr)
idebug = InStr(sstr, "L")
iStartLoc = InStr(sstr, "S")
iEndLoc = InStr(sstr, "E")
iDurLoc = InStr(sstr, "D")
iCommaALoc = InStr(sstr, ",")
iCommaBLoc = InStr((iCommaALoc + 1), sstr, ",")
iTimeLen = (iCommaALoc - 5) - (iStartLoc + 12) + 1
siStartLk(iTrialctr, iLkctr) = CSng(Mid(sstr, iStartLoc + 12, iTimeLen)) 'The line tossing problems
iTimeLen = ((iCommaBLoc - 1) - (iEndLoc + 10)) + 1
siEndLk(iTrialctr, iLkctr) = CSng(Mid(sstr, (iEndLoc + 10), iTimeLen))
If InStr(sstr, "COUNTED") = 0 Then
iTimeLen = (iStrLen - (iDurLoc + 10)) - 19
Else
iTimeLen = (iStrLen - (iDurLoc + 10)) - 19
End If
siLkDur(iTrialctr, iLkctr) = CSng(Mid(sstr, (iDurLoc + 10), iTimeLen))
iLkctr = iLkctr + 1
End If
iRow = iRow + 1
I need to extract the "0.2" from the string, and place it into an array, however, it tosses an error, and while debugging, siStartLk(iTrialctr, iLkctr) shows siStartLk(iTrialctr, iLkctr) = <Subscript out of range>. Where iTrialctr and iLkctr are both 1 (first trial, first look, so it essentially gets caught instantly). I've checked and counted the indexes correctly, I THINK.
When the program breaks these are the following values:
iStartLoc = 38 (index of "S") (the + 12 gives 50, '0' in '0.2')
iTimeLen = 3 (which it should be, '0.2')
iCommaALoc = 57 (-5, is '2' in '0.2'
Am I missing something?
Bookmarks