主题:[原创]请教高手关于输入法生成器的问题
这是输入法生成器的代码,但是我看半天不知道是什么意思,请各位高手给解答一下,万分的感谢
Option Explicit
Private mStrings As Collection
Private Sub Class_Terminate()
On Error Resume Next
Set mStrings = Nothing
End Sub
'CSEH: Syx_ErrMsgBox-Resume-Return
Public Function MakeTxtAddress() As Boolean
'<EhHeader>
On Error GoTo DoErr
MakeTxtAddress = True
'</EhHeader>
Set mStrings = Nothing
Set mStrings = New Collection
Set mStrings = LoadStrings(App.Path & "\Output\pinyin.txt")
MakeTxtAddress = WriteBin
If Not MakeTxtAddress Then
Err.Raise 600, , "拼音地址生成失败!"
End If
'<EhFooter>
Exit Function
DoErr:
If MsgBox(CStr(vbObjectError + 100) & Err.Source & vbCrLf & _
"数据下载.CDish.MakeTxtAddress" & vbCrLf & Err.Description & _
"是否继续执行?", vbYesNo) = vbYes Then
MakeTxtAddress = False
Resume Next
Else
MakeTxtAddress = False
End If
'</EhFooter>
End Function
'CSEH: Syx_ErrMsgBox-Resume-Return
Private Function WriteBin() As Boolean
'<EhHeader>
On Error GoTo DoErr
WriteBin = True
'</EhHeader>
Dim eachStr As Variant
Dim dishNos As String
Dim dishNames As Variant
Dim dishNo As String
Dim dishName As String
Dim dishAddr As String
Dim nameAddr As Long
Dim BinaryArray() As Byte
nameAddr = 0
For Each eachStr In mStrings
dishNo = StrConv(Left$(eachStr, 6), vbFromUnicode)
dishName = Mid$(eachStr, 7)
dishAddr = vbNullString
nameAddr = LenB(StrConv(dishNames, vbFromUnicode))
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(0) + dishAddr
dishAddr = SetLong(nameAddr, False)
nameAddr = LenB(StrConv(dishName, vbFromUnicode))
'--- 索引文件: 拼音(6) + 地址(4) + 汉字个数(1)
dishNos = dishNos + dishNo + dishAddr + ChrB$(nameAddr \ 2)
'--- 内容文件: 汉字串
dishNames = dishNames + dishName
Next
Call DeleteFile(App.Path & "\Output\PinYinChsIndex.bin")
Open App.Path & "\Output\PinYinChsIndex.bin" For Binary As #1
BinaryArray = dishNos
Put #1, , BinaryArray
Close #1
Call SaveStringsToFile(App.Path & "\Output\PinYinChsWord.bin", dishNames, False)
'<EhFooter>
Exit Function
DoErr:
If MsgBox(CStr(vbObjectError + 100) & Err.Source & vbCrLf & _
"数据下载.CDish.WriteMenu" & vbCrLf & Err.Description & _
"是否继续执行?", vbYesNo) = vbYes Then
WriteBin = False
Resume Next
Else
WriteBin = False
End If
'</EhFooter>
End Function
Option Explicit
Private mStrings As Collection
Private Sub Class_Terminate()
On Error Resume Next
Set mStrings = Nothing
End Sub
'CSEH: Syx_ErrMsgBox-Resume-Return
Public Function MakeTxtAddress() As Boolean
'<EhHeader>
On Error GoTo DoErr
MakeTxtAddress = True
'</EhHeader>
Set mStrings = Nothing
Set mStrings = New Collection
Set mStrings = LoadStrings(App.Path & "\Output\pinyin.txt")
MakeTxtAddress = WriteBin
If Not MakeTxtAddress Then
Err.Raise 600, , "拼音地址生成失败!"
End If
'<EhFooter>
Exit Function
DoErr:
If MsgBox(CStr(vbObjectError + 100) & Err.Source & vbCrLf & _
"数据下载.CDish.MakeTxtAddress" & vbCrLf & Err.Description & _
"是否继续执行?", vbYesNo) = vbYes Then
MakeTxtAddress = False
Resume Next
Else
MakeTxtAddress = False
End If
'</EhFooter>
End Function
'CSEH: Syx_ErrMsgBox-Resume-Return
Private Function WriteBin() As Boolean
'<EhHeader>
On Error GoTo DoErr
WriteBin = True
'</EhHeader>
Dim eachStr As Variant
Dim dishNos As String
Dim dishNames As Variant
Dim dishNo As String
Dim dishName As String
Dim dishAddr As String
Dim nameAddr As Long
Dim BinaryArray() As Byte
nameAddr = 0
For Each eachStr In mStrings
dishNo = StrConv(Left$(eachStr, 6), vbFromUnicode)
dishName = Mid$(eachStr, 7)
dishAddr = vbNullString
nameAddr = LenB(StrConv(dishNames, vbFromUnicode))
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(nameAddr Mod 256) + dishAddr
' nameAddr = nameAddr \ 256
'
' dishAddr = ChrB$(0) + dishAddr
dishAddr = SetLong(nameAddr, False)
nameAddr = LenB(StrConv(dishName, vbFromUnicode))
'--- 索引文件: 拼音(6) + 地址(4) + 汉字个数(1)
dishNos = dishNos + dishNo + dishAddr + ChrB$(nameAddr \ 2)
'--- 内容文件: 汉字串
dishNames = dishNames + dishName
Next
Call DeleteFile(App.Path & "\Output\PinYinChsIndex.bin")
Open App.Path & "\Output\PinYinChsIndex.bin" For Binary As #1
BinaryArray = dishNos
Put #1, , BinaryArray
Close #1
Call SaveStringsToFile(App.Path & "\Output\PinYinChsWord.bin", dishNames, False)
'<EhFooter>
Exit Function
DoErr:
If MsgBox(CStr(vbObjectError + 100) & Err.Source & vbCrLf & _
"数据下载.CDish.WriteMenu" & vbCrLf & Err.Description & _
"是否继续执行?", vbYesNo) = vbYes Then
WriteBin = False
Resume Next
Else
WriteBin = False
End If
'</EhFooter>
End Function