I was able to extract the code from the barcode but when reading the magnetic script from a OHIO drivers license I cannot seem to get the two letter code that prefixes the license number like the PDF417 does.
Private Sub ScannDLButton_Click(sender As Object, e As EventArgs) Handles ScanDLButton.Click
Try
Dim strInputBox As String = InputBox("Please Swipe/Scan Customer's Driver's License", "Driver's License")
Dim strLastName As String
Dim strFirstName As String
Dim strMiddleName As String
Dim strDOB As String
Dim strStreet As String
Dim strCity As String
Dim strState As String
Dim strZIP As String
Dim strDL As String
Dim strCountry As String
this determines if it is a magnetic strip
If strInputBox.Contains("%") Then
Dim CaretPresent As Boolean = False
Dim EqualPresent As Boolean = False
CaretPresent = strInputBox.Contains("^")
EqualPresent = strInputBox.Contains("=")
If CaretPresent Then 'track one
Dim CardData As String() = strInputBox.Split("^"c)
strState = CardData(0).Substring(1, 2)
strCity = CardData(0).Substring(3, CardData(0).Length - 3)
Dim strname As String() = CardData(1).Split("$"c)
strLastName = strname(0)
strFirstName = strname(1)
strMiddleName = strname(2)
strStreet = CardData(2)
Dim strzipcode As String() = CardData(3).Split("+"c)
strZIP = strzipcode(1).Substring(2, 5)
End If
If EqualPresent Then ' track two
Dim CardData As String() = strInputBox.Split("="c)
strDOB = CardData(1).Substring(6, 6)
End If
this determines if the user scanned a barcode on back of the license
ElseIf strInputBox.Contains("ANSI") Then
Dim separatingStrings As String() = {"ANSI", "DBA", "DCS", "DAC", "DAD", "DBD", "DBB", "DBC", "DAY", "DAU", "DAG", "DAI", "DAJ", "DAK", "DAQ", "DCF", "DCG", "DDE", "DDF", "DDG", "DAZ", "DCI", "DCJ", "DCU", "DCE", "DDA", "DDB", "DAW", "DDK", "ZOZ", "ZOE"}
Dim text As String = strInputBox
Dim words As String() = text.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries)
Dim i As Integer = 0
For Each word In words
_log.Info("Looking at code: " & separatingStrings(i).ToString)
_log.Info("Parsing field: " & word.ToString.Trim)
strLastName = IIf(separatingStrings(i) = "DCS", word.ToString.Trim, strLastName)
strFirstName = IIf(separatingStrings(i) = "DAC", word.ToString.Trim, strFirstName)
strMiddleName = IIf(separatingStrings(i) = "DAD", word.ToString.Trim, strMiddleName)
strDOB = IIf(separatingStrings(i) = "DBB", word.ToString.Trim, strDOB)
strStreet = IIf(separatingStrings(i) = "DAG", word.ToString.Trim, strStreet)
strCity = IIf(separatingStrings(i) = "DAI", word.ToString.Trim, strCity)
strState = IIf(separatingStrings(i) = "DAJ", word.ToString.Trim, strState)
strZIP = IIf(separatingStrings(i) = "DAK", word.ToString.Trim, strZIP)
strDL = IIf(separatingStrings(i) = "DAQ", word.ToString.Trim, strDL)
strCountry = IIf(separatingStrings(i) = "DCG", word.ToString.Trim, strCountry)
i += 1
Next
Else
MessageBox.Show("Incorrect format, contact us with this type of ID", "Scan Driver's License", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Return
End If
Is there code encrypted code within the text line.
I know this is an old question, but maybe someone will still find this answer helpful.
It appears, at least for Ohio, that the two letter license number prefix is represented by the ordinal number of the alphabet (A=01 .. Z=26).
So in the sample data ";6360231911247481" the "636023" is Ohio's ANSI Id prefix and "19" is the ordinal of the first letter ("S") and "11" is the ordinal of the second letter ("K"), with "247481" being the remaining numeric portion.
So for this example, the full DL Number is "SK247481".
Note that this was determined from sample data and not a documented source, so ymmv.