Can I do a binary text search on an access database?

Visual Studio54
Hi All,



I found this code to do a search and index on a text file.

I was wondering if I could this code instead on an access table?



Private Sub Form_Load()

Dim D As Dictionary, WC&, FName$, T#, K

FName = "c:\huck.txt"

T = Timer

WC = ProcessFile(FName, D)

With Controls.Add("vb.listbox", "LB")

.AddItem "Word-Counting: " & Timer - T & " sec"

.AddItem FileLen(FName) & " FileLen"

.AddItem WC & " unfiltered words"

.AddItem D.Count & " filtered words"

.AddItem "Word-History:"

For Each K In D

.AddItem K & " (" & D(K) & ")"

Next K

.Move 0, 0, ScaleWidth, ScaleHeight

.Visible = True

End With

Caption = "Total Time: " & Timer - T & " sec"

End Sub



Public Function ProcessFile&(FName$, D As Dictionary)

Dim i&, j&, Pos1&, Pos2&, W() As Byte, WW$

Dim FNr&, FLen&, B() As Byte, WC&, S$

Set D = New Dictionary: D.CompareMode = BinaryCompare



On Error Resume Next

FLen = FileLen(FName)

On Error GoTo 0

If FLen = 0 Then Exit Function



ReDim B(FLen) '1 Byte more than necessary

FNr = FreeFile: Open FName For Binary As FNr

Get FNr, , B: Close FNr

S = StrConv(B, vbUnicode)



For i = 0 To UBound(B)

Do: Select Case B(i)

Case 48 To 57, 65 To 90, 97 To 122, 127 To 255: Pos1 = i

Case Else: i = i + 1: If i>UBound(B) Then Exit For

End Select

Loop Until Pos1 = i

Do: Select Case B(i)

Case 48 To 57, 65 To 90, 97 To 122, 127 To 255: i = i + 1

Case Else: Pos2 = i

End Select

Loop Until Pos2 = i



WW = Mid$(S, Pos1 + 1, Pos2 - Pos1) 'Word found (WW)

D(WW) = D(WW) + 1

WC = WC + 1

Next i

ProcessFile = WC

End Function



Regards



Marco


-