Dim sCodeType As String 'I could do this as a numeric value. However, I will do it as a string for easy viewing.
Private Sub chkFormat_Click(Index As Integer)
txtCode.SetFocus
End Sub
Private Sub Form_Load()
Dim i As Byte
For i = 0 To 3 'Clear all the Data from the Form
lblData(i).Caption = ""
Next i
End Sub
Private Sub optFormat_Click(Index As Integer)
txtCode.SetFocus
End Sub
Private Sub txtCode_Change()
Dim nDecimals As Byte
Dim i As Integer
If InStr(txtCode.Text, vbCrLf) <> 0 Then 'check for <CR>
For i = 0 To 3 'Clear all the Data from the Form
lblData(i).Caption = ""
Next i
For i = 1 To Len(txtCode.Text) 'Search for the decimals
If Mid$(txtCode.Text, i, 1) = "." Then nDecimals = nDecimals + 1
If nDecimals = 3 Then '3rd decimal is the start of the data to be decoded.
sCueBuffer = Mid$(txtCode.Text, i + 1) 'Remove the header prefix (before the 3rd decimal)
sCueBuffer = Left$(sCueBuffer, Len(sCueBuffer) - 3) 'Remove the trailing decimal and the <CR>
Exit For 'Exit For/Next Statement
End If
Next i
If InStr(txtCode.Text, ".CNf7.") <> 0 Then 'CODE 128
sCodeType = "CODE128"
lblData(0).Caption = "CODE 128"
ElseIf InStr(txtCode.Text, ".ahb6.") <> 0 Then 'CODE 39
sCodeType = "CODE39"
lblData(0).Caption = "CODE 39"
lblData(3).Caption = "A-Z (uppercase), 0-9, period/decimal, space, $, /, + and %." & vbCrLf & "This version of the source does not implement A-Z or special characters."
ElseIf InStr(txtCode.Text, ".fHmc.") <> 0 Then 'UPC A (12 Digits)
sCodeType = "UPCA12"
lblData(0).Caption = "UPC A (10 + Check Digit)"
lblData(3).Caption = "UPC A consists of digits 0-9" + vbCrLf + "First Digit: Number System Digit" + vbCrLf + "Next 5 Digits: Manufacturer Code" + vbCrLf + "Next 5 Digits: Product ID" + vbCrLf + "Last Digit: Checksum Digit"
lblData(0).Caption = "UPC / ISBN +5 Digit Ext. (18 Digits)"
lblData(3).Caption = "Consists of digits 0-9" + vbCrLf + "Found usually on Books and Magazines" + vbCrLf + "Also includes the ISBN number"
ElseIf InStr(txtCode.Text, ".cGen.") <> 0 Then 'UPC 5 Digit Extension (13 Digits) minus the 5 digits
sCodeType = "UPC513"
lblData(0).Caption = "UPC / ISBN (13 Digits)"
lblData(3).Caption = "Consists of digits 0-9" + vbCrLf + "Same as the 18 digit version minus the 5 digit extension." + vbCrLf + "For some reason the 13th digit seems to repeat the 12th digit."
Else 'All other formats that are not implemented or unknown
sCodeType = "UNKNOWN"
lblData(0).Caption = "Unknown/Not Implemented"
End If
txtCode.Text = ""
If optFormat(0).Value = True Then 'Format the Data