這需要一個解決方案&從VB6遷移到Access的代碼如下。 我有一個函數來比較來自VB6的字符,我是VB6的新手用戶,主要工作於VBA平臺。我需要在MS Access中設置一個類或更好的方法來檢查字符的字符錯誤,而不使用UDT。字符比較QWERTY Key Proximity Typo(Access VBA Equivalent)
Mytypolist作爲數組是指以下數據集: QWA WESAQ ERDSW RTFDE TYGFR YUHGT UIJHY IOKJU OPLKI PLO AQWSZ SEDXZA DRFCXSE FTGVCDR GYHBVFT HUJNBGY JIKMNHU KOLMJI LPKO ZASX XZSDC CXDFV VCFGB BVGHN NBHJM MNJK
上述數據用於比較一個字是否在一個單詞中錯誤輸入。如果我在Auebec中使用A而不是我的意思是鍵入魁北克,我的興趣集羣是QWA; WESAQ; AQWSZ;或基於接近度的標準英文Qwerty鍵盤上的任何其他Q排列。這不僅適用於Q,而且適用於整套字母,無論大小寫如何,所以c都有自己的可能的錯字匹配等。
在UDF(用戶定義類型)的VB6設置中: 'declare UDT type for typos
Public Type Mytypos
Rightrkey As String * 1
PossibleKey As String * 8
End Type
'declare arrays and variable for master list and typos
Public Masterlist() As String
Public Mytypolist(26) As Mytypos
Public Matchkey As Mytypos
以下函數比較兩個單詞;並通過計算currentpct分數分配相似:
Public Function CompareCharacters(ByRef MasterWord As String, _
ByRef Checkword As String, ByRef CurrentPCT As Double, _
ByRef WordVal As Long) As Double
'define function variables
Dim ChrCount As Long
Dim ChrValue As Long
Dim loop1 As Long
Dim loop2 As Long
'define the letter values
If Len(MasterWord) > Len(Checkword) Then
ChrCount = Len(MasterWord) * 2
Else
ChrCount = Len(Checkword) * 2
End If
ChrValue = 1/ChrCount
'say CURRENT PCT has a value of 10%
'check each letter for a match in current word position
For loop1 = 1 To Len(Checkword)
'check for typo errors (key proximity)
For loop2 = 0 To UBound(Mytypolist)
Matchkey = Mytypolist(loop2)
'if indexkey = letter in masterword
If Matchkey.Rightrkey = Mid(MasterWord, loop1, 1) Then
'does the letter in the checkword exist in the proximity keylist
If InStr(1, Matchkey.PossibleKey, Mid(Checkword, loop1, 1), vbTextCompare) > 0 Then
'value for letter found in proximity keylist
CurrentPCT = CurrentPCT + ChrValue
End If
Exit For
End If
Next loop2
Next loop1
CompareCharacters = CurrentPCT
End Function
,如果你能發佈我一個陣列/類的解決方案,可能不會產生編譯器問題(字符串UDT在VBA是一個問題)。請立即查看!
謝謝PhoenixX_2。讓我編譯一下,看看它是否有效。 – user2697019