📄 frmmain.frm
字号:
intCounter = 0
Filename_Database = "DATA" & recordFileExtension
Filename_buttonLearn = Filename_Database
intCounter = intCounter + 1
Call GraspRawData
If strData = "" Then
Call buttonClearScreen_Click
Me.buttonLearn.Enabled = Not Me.buttonLearn.Enabled
MsgBox "Detect No character was drawn in the Draw Area. buttonLearn operation can not be proceed. ", vbExclamation, "Warning..."
GoTo buttonLearnConfirm_SkipbuttonLearn
End If
Open Filename_buttonLearn For Binary As #1
strBuffer = Space(5)
Get #1, , strBuffer
Close #1
If strBuffer = "recPK" Then
' add buttonLearning character as binary
'**
strRECpk = ""
strBuffer = ""
Open Filename_buttonLearn For Binary As #1
strBuffer = Space(5)
Get #1, , strBuffer
strRECpk = strRECpk & strBuffer
strBuffer = Space(22)
While Not EOF(1)
Get #1, , strBuffer
strRECpk = strRECpk & strBuffer
Wend
Close #1
strRECpk = Mid(strRECpk, 1, Len(strRECpk) - 22)
i = 3
strRECpk = strRECpk & strbuttonLearnText
strRECpk = strRECpk & ","
For j = 1 To 10
strRECpk = strRECpk & Chr(BinToDec(Mid(strData, i - 2 + ((j - 1) * 10), 2)))
strRECpk = strRECpk & Chr(BinToDec(Mid(strData, i + 0 + ((j - 1) * 10), 8)))
Next j
Open Filename_buttonLearn For Binary As #1
Put #1, , strRECpk
Close #1
Else
' add buttonLearning character as string
Open Filename_buttonLearn For Append As #1
Write #1, strbuttonLearnText & "," & strData
Close #1
'**
End If
buttonLearnConfirm_SkipbuttonLearn:
Me.TeachLabelText.FontBold = True
Me.TeachLabelText.Caption = strCaption
Me.buttonLearnConfirm.Visible = False
Me.buttonLearnCancel.Visible = False
Me.inputLearnCharacter.Visible = False
Me.buttonLearn.Enabled = False
Me.buttonLearn.Visible = True
Me.buttonRecognise.Visible = True
Me.buttonClearScreen.Visible = True
End Sub
Private Sub Image1_Click()
frmSplash.Show
frmSplash.Refresh
End Sub
Private Sub Label1_Click()
frmAbout.Show
frmAbout.Refresh
End Sub
Private Sub userDrawArea_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
currentlyDrawing = True
userDrawArea.DrawWidth = 17
userDrawArea.PSet (x, y)
If Not Me.buttonLearn.Enabled Then
Me.buttonLearn.Enabled = True
Me.buttonRecognise.Enabled = True
Me.buttonClearScreen.Enabled = True
End If
If Not Me.buttonRecognise.Enabled Then
Me.buttonRecognise.Enabled = True
End If
End Sub
Private Sub userDrawArea_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
userDrawArea.DrawStyle = vbSolid
userDrawArea.DrawWidth = 17
If currentlyDrawing Then
userDrawArea.PSet (x, y)
If Not fMainForm.buttonLearn.Enabled Then
Me.buttonLearn.Enabled = True
Me.buttonRecognise.Enabled = True
Me.buttonClearScreen.Enabled = True
End If
End If
End Sub
Private Sub userDrawArea_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
currentlyDrawing = False
Call GraspRawData
End Sub
Private Sub Exit_Click()
' MsgBox "Are you sure want to Exit?", vbYesNo, "Confirmation"
' If vbYes Then
' Unload Me
' End If
' frmConfirmation.Left = (frmMain.Width / 2) - (frmConfirmation.Width / 2)
' frmConfirmation.Top = (frmMain.ScaleHeight / 2) - (frmConfirmation.Height)
frmConfirmation.Show vbModal
If frmConfirmation.YES Then
Unload Me
End If
End Sub
Private Sub Form_Load()
recordFileExtension = ".rec"
strCaption = "The software is ready for processing"
Me.TeachLabelText.FontBold = True
Me.TeachLabelText.Caption = strCaption
Me.userTemplateArea.DrawWidth = 2
Me.AppTemplateArea.DrawWidth = 2
Me.buttonLearn.Enabled = False
Me.buttonRecognise.Enabled = False
Me.buttonClearScreen.Enabled = False
Me.inputLearnCharacter.Visible = False
Me.buttonLearnConfirm.Visible = False
Me.buttonLearnCancel.Visible = False
Me.progressRecognition.Value = 0
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
Me.PopupMenu mnuPopUp
End If
End Sub
Private Sub mnuPopUp_About_Click()
Dim AboutDialog As New frmAbout
AboutDialog.Show vbModal
End Sub
Private Sub mnuPopUp_Close_Click()
Call Exit_Click
End Sub
Private Sub buttonRecognise_Click()
Dim Filename_Database As String
Dim strbuttonRecognised As String
Dim intMatch As Integer
Dim intMaxMatch As Integer
Dim intCounter As Integer
Dim boolFindLastFile As Boolean
Dim boolNoMoreFileLeft As Boolean
Dim buffer As String
Dim Buffer_DatabaseArea As Variant
Dim strBuffer As String
FileSystem.ChDir (App.Path)
strbuttonRecognised = ""
intMaxMatch = 0
intCounter = 0
c = 0
On Error GoTo buttonRecognise_FileClose
Filename_Database = "DATA" & recordFileExtension
If Filename_Database <> "" Then
Me.AppTemplateArea.Cls
Open Filename_Database For Binary As #1
i = 0
strBuffer = Space(5)
Get #1, , strBuffer
arrRawData(i) = strBuffer
i = i + 1
strBuffer = Space(22)
While Not EOF(1)
Get #1, , strBuffer
arrRawData(i) = strBuffer
i = i + 1
Wend
arrRawData(i - 1) = ""
Close #1
i = 0
strBuffer = ""
If arrRawData(0) = "recPK" Then
i = i + 1
strbuttonRecognised = ""
intMaxMatch = 0
intCounter = 0
c = 0
While arrRawData(i) <> ""
a = 190
b = 190
d = 0
intMatch = 0
Me.AppTemplateArea.Cls
arrTagData(i - 1) = Mid(arrRawData(i), 1, 1)
' strBuffer = strBuffer & Mid(strData(i), 1, 1) & vbCrLf
' strBuffer = strBuffer & Mid(strData(0), i, 1) & ","
' Me.ListBox_List.AddItem i & ". <" & Mid(strData(i), 1, 1) & ">"
arrRawData(i - 1) = ""
For j = 1 To 10
' strBuffer = strBuffer & DecToBin(Asc(Mid(strData(i), 3 + ((j - 1) * 2), 1)), 2)
' strBuffer = strBuffer & DecToBin(Asc(Mid(strData(i), 4 + ((j - 1) * 2), 1)), 8)
arrRawData(i - 1) = arrRawData(i - 1) & _
DecToBin(Asc(Mid(arrRawData(i), 3 + ((j - 1) * 2), 1)), 2) & _
DecToBin(Asc(Mid(arrRawData(i), 4 + ((j - 1) * 2), 1)), 8)
' strBuffer = strBuffer
Next j
' strBuffer = strBuffer & vbCrLf
i = i + 1
For ii = 1 To 10
For jj = 1 To 10
If Mid(arrRawData(c), d + 1, 1) = vbBlack Then
' userTemplateArea.PSet (i, j)
' j2 - mask - finalise
' AppTemplateArea.PSet (a, b)
' userTemplateArea.Circle (a, b), 110
' AppTemplateArea.Line (a - 110, b - 110)-(a + 110, b - 110)
' AppTemplateArea.Line (a + 110, b - 110)-(a + 110, b + 110)
' AppTemplateArea.Line (a + 110, b + 110)-(a - 110, b + 110)
' AppTemplateArea.Line (a - 110, b + 110)-(a - 110, b - 110)
' Debug.Print ""
If Mid(strData, d + 1, 1) = vbBlack Then
intMatch = intMatch + 1
Else
intMatch = intMatch - 1
End If
Else
If Mid(strData, d + 1, 1) <> vbBlack Then
intMatch = intMatch + 1
Else
intMatch = intMatch - 1
End If
End If
d = d + 1
b = b + (Me.AppTemplateArea.Height - 200) / 10
Next jj
b = 190
a = a + (Me.AppTemplateArea.Width - 200) / 10
Next ii
If intMaxMatch < intMatch Then
intMaxMatch = intMatch
strbuttonRecognised = arrTagData(c)
intCounter = c
Me.progressRecognition.Value = intMaxMatch
If intMaxMatch > 90 Then
GoTo buttonRecognise_FileClose
End If
End If
c = c + 1
Wend
' Me.RichTextBox_Text.Text = strBuffer
' Me.TextBox_Text.ScrollBars
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -