Re: Cannot solve complex problem
- From: "Schmidt" <sss@xxxxxxxxx>
- Date: Sun, 6 Apr 2008 18:31:23 +0200
"Keith Stemmer" <k.stemmer@xxxxxxxxxxx> schrieb im Newsbeitrag
news:eCrPKv9lIHA.5160@xxxxxxxxxxxxxxxxxxxxxxx
The only thing that scares me is the callback. My idea of aThe wrapper encapsulates all the API-Stuff for you.
callback is crashing little beast.
You have only to define a small Class, which implements
an Interface - and add this Class to the Cnn-Object -
that's all (but look below - at the SourceCode)
I have not been able to find what you told me in your demo.The examples, how to implement userdefined Function-
Can you point me to the right direction, please?
Interfaces as well as userdefined Collations are in
fUserDefinedFunctions and the Interface-Classes
cMyFunctions, cMyAggFunction and cMyCollations.
And the wrapper as it comes as Binary has already
preimplemented VB-Functions as LCase$, UCase$
and Like, which *deaktivate* (override) the original
"non-unicode-aware" SQLite-Pendants - as said,
as long as you use a Like-Compare over my wrapper,
you work unicode-aware against the real VB6-Like.
For example I need to search recordsets that haveThat's covered in the example below.
last name 'Ölmer' as well as 'ölmer',
and maybe even worse for SQLite, it may even be 'deAlso covered by the example below, using a userdefined
Ölmer'.
Collation (without AddrOf-stuff, only a simple to implement
Class).
'****Into a Form
Private Sub Form_Load()
Dim Cnn As cConnection, Rs As cRecordset, SQL$
Set Cnn = New cConnection
Cnn.CreateNewDB 'create a InMemoryDb for our small Demo
'now create a Test-Table T with three simple records:
Cnn.Execute "Create Table T(ID Integer Primary Key, LastName Text)"
Cnn.Execute "Insert Into T Values(1, 'ölmer')"
Cnn.Execute "Insert Into T Values(2, 'Ölmer')"
Cnn.Execute "Insert Into T Values(3, 'Oelmer')"
'and now we make use of the unicode-aware
'function-overrides of the wrapper, they are already
'there (in dhRichClient.dll), nothing to define separately
Debug.Print vbCrLf; "first the caseinsensitive Like:"
SQL = "Select * From T Where LastName Like 'ö%'"
Set Rs = Cnn.OpenRecordset(SQL)
Do Until Rs.EOF
Debug.Print Rs!LastName
Rs.MoveNext
Loop
Debug.Print vbCrLf; "now a caseinsensitive exact-compare:"
SQL = "Select * From T Where LCase$(LastName) = 'ölmer'"
Set Rs = Cnn.OpenRecordset(SQL)
Do Until Rs.EOF
Debug.Print Rs!LastName
Rs.MoveNext
Loop
Debug.Print vbCrLf; "another option for a caseinsensitive compare:"
'the wrapper conatins also an override for SQLites-NoCase-Collation
'to achieve unicode-awareness, which the original doesn't support
SQL = "Select * From T Where (LastName = 'ölmer' Collate NoCase)"
Set Rs = Cnn.OpenRecordset(SQL)
Do Until Rs.EOF
Debug.Print Rs!LastName
Rs.MoveNext
Loop
'*********************
'And now let's enhance the last, collation-based approach
'using our own, userdefined Collation-Definitions.
'We defined two of them in a small Class, which we
'tell the wrapper to use now.
Cnn.AddUserDefinedCollation New cMyCollations
Debug.Print vbCrLf; "another caseinsensitive compare using DE:"
SQL = "Select * From T Where (LastName = 'ölmer' Collate DE)"
Set Rs = Cnn.OpenRecordset(SQL)
Do Until Rs.EOF
Debug.Print Rs!LastName
Rs.MoveNext
Loop
Debug.Print vbCrLf; "and finally the same compare using DE_PhoneBook:"
SQL = "Select * From T Where (LastName = 'ölmer' Collate DE_PhoneBook)"
Set Rs = Cnn.OpenRecordset(SQL)
Do Until Rs.EOF
Debug.Print Rs!LastName
Rs.MoveNext
Loop
End Sub
'***and here comes the small Class, which demonstrates, how
' to Implement the small Interface for userdefinable Collations
' call this Class cMyCollations
Option Explicit
Implements ICollation
Private SC As cStringCompare, LCID_DE As Long, LCID_DE_PhoneBook As Long
'here we define two collation-names as a comma-separated "list"
Private Property Get ICollation_DefinedNames() As String
ICollation_DefinedNames = "DE,DE_Phonebook"
End Property
Private Function ICollation_CallbackCollate(ByVal ZeroBasedNameIndex&, _
S1 As String, S2 As String) As Long
Select Case ZeroBasedNameIndex
'DE (the first entry in the comma-separated list
'in ICollation_DefinedNames)
Case 0
ICollation_CallbackCollate = SC.CompareString(S1, S2, _
cmpIgnoreCase, LCID_DE)
'DE-Phonebook (the second entry in the comma-separated list
'in ICollation_DefinedNames)
Case 1
ICollation_CallbackCollate = SC.CompareString(S1, S2, _
cmpIgnoreCase, LCID_DE_PhoneBook)
End Select
End Function
Private Sub Class_Initialize()
'dhRichClient comes with a ClassWrapper for the CompareString-API
Set SC = New cStringCompare
'let's create and store two different LCIDs at Class-Level
LCID_DE = SC.MakeLCID(German_Germany)
LCID_DE_PhoneBook = SC.MakeLCID(German_Germany, SORT_GERMAN_PHONE_BOOK)
End Sub
Olaf
.
- Follow-Ups:
- Re: Cannot solve complex problem
- From: Keith Stemmer
- Re: Cannot solve complex problem
- References:
- VB6: Cannot solve complex problem
- From: Keith Stemmer
- Re: Cannot solve complex problem
- From: Schmidt
- Re: Cannot solve complex problem
- From: Keith Stemmer
- Re: Cannot solve complex problem
- From: Schmidt
- Re: Cannot solve complex problem
- From: Keith Stemmer
- Re: Cannot solve complex problem
- From: Schmidt
- Re: Cannot solve complex problem
- From: Keith Stemmer
- VB6: Cannot solve complex problem
- Prev by Date: Re: Not showing form's outline when resizing
- Next by Date: Re: Beginner VB user has a technical question.
- Previous by thread: Re: Cannot solve complex problem
- Next by thread: Re: Cannot solve complex problem
- Index(es):
Relevant Pages
|