' Recieves OMR group zones information (e.g.: 0|1|0|0|0) and returns the index of the marked zone (single choice) ' Returns -1 if: no zone is marked (nothing is selected) ' Returns -2 if: more than one zone were selected ' Returns -3 if: at least one uncertain marking is present Public Function OMRSingleChoiceIndex(omrValues As String, markedZoneChar As String, delimiterChar As String, uncertainChar As String) As Integer Dim tmpArray() As String Dim i As Integer Dim countOfMarkedZones As Integer Dim markedIndex As Integer ' check for uncertain zones - this is the fastest check possible If InStr(omrValues, uncertainChar) <> 0 Then OMRSingleChoiceIndex = -3 Exit Function End If tmpArray = Split(omrValues, delimiterChar) countOfMarkedZones = 0 For i = 0 To UBound(tmpArray) ' count each marked zone and store last marked position If tmpArray(i) = markedZoneChar Then countOfMarkedZones += 1 markedIndex = i End If Next OMRSingleChoiceIndex = markedIndex If countOfMarkedZones = 0 Then OMRSingleChoiceIndex = -1 If countOfMarkedZones > 1 Then OMRSingleChoiceIndex = -2 End Function