Bonjour à tous,
j'ai récupérer du code VB qui permet de comparer 2 chaines et qui retournent un %.
Je bloque à plusieurs partie du code VB car je n'en ai jamais fait.
le VB:
mon code windev pour l'instant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 Private Declare Sub RtlMoveMemory Lib "kernel32" (Destination As Any, Source As Any, ByVal Length As Long) Private b1() As Byte Private b2() As Byte Public Function Comparer(ByVal string1 As String, ByVal string2 As String) As Double Dim len1 As Long Dim len2 As Long string1 = UCase$(string1) string2 = UCase$(string2) If string1 = string2 Then Comparer = 1 Else len1 = Len(string1) len2 = Len(string2) ReDim b1(1 To len1) ReDim b2(1 To len2) RtlMoveMemory b1(1), ByVal string1, len1 RtlMoveMemory b2(1), ByVal string2, len2 Comparer = SubSim(1, len1, 1, len2) / (len1 + len2) * 2 End If End Function Private Function SubSim(st1 As Long, end1 As Long, st2 As Long, end2 As Long) As Long If Not (st1 > end1 Or st2 > end2 Or st1 <= 0 Or st2 <= 0) Then Dim c1 As Long Dim c2 As Long Dim ns1 As Long Dim ns2 As Long Dim i As Long Dim max As Long For c1 = st1 To end1 For c2 = st2 To end2 i = 0 Do Until b1(c1 + i) <> b2(c2 + i) i = i + 1 If i > max Then ns1 = c1 ns2 = c2 max = i End If If c1 + i > end1 Or c2 + i > end2 Then Exit Do Loop Next c2 Next c1 SubSim = max + SubSim(ns1 + max, end1, ns2 + max, end2) + SubSim(st1, ns1 - 1, st2, ns2 - 1) End If End Function
Pour l'instant mon erreur se situe dans l'appel de RtlMoveMemory
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 PROCEDURE Comparer(string1 est une chaîne,string2 est une chaîne) b1_ est un tableau d'entier B2_ est un tableau d'entier nLengh1 est un entier nLengh2 est un entier string1 = Majuscule(string1) string2 = Majuscule(string2) nTest est un entier SI string1 = string2 ALORS nTest = 1 SINON nLengh1 = Taille(string1) nLengh2 = Taille(string2) TableauAjoute(b1_,nLengh1) TableauAjoute(B2_,nLengh2) AppelDLL32("kernel32","RtlMoveMemory",b1_[1],string1,nLengh1) AppelDLL32("kernel32","RtlMoveMemory",B2_[2],string2,nLengh2) nTest = subSim(1, nLengh1, 1, nLengh2) / (nLengh1 + nLengh2) * 2 FIN RENVOYER nTest // PROCEDURE subSim(st1,st2,end1,end2) SI PAS (st1 > end1 OU st2 > end2 OU st1 <= 0 OU st2 <= 0) ALORS c1 est un entier c2 est un entier nS1 est un entier nS2 est un entier i est un entier nMax est un entier nTest est un entier POUR c1 = st1 A end1 POUR c2 = st2 A end2 i = 0 TANTQUE b1[c1 + i] <> b2[c2 + i] i = i +1 SI i > nMax ALORS nS1 = c1 nS2 = c2 nMax = i FIN SI c1 + i > end1 OU c2 + i > end2 ALORS FIN FIN c2++ FIN c1++ FIN FIN nTest = nMax + subSim(nS1+nMax, end1, nS2 + nMax , end2) + subSim(st1,nS1-1,st2,nS2 - 1) RENVOYER nTest
Si vous pouviez me donnez un petit coup de pouce..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Que s'est-il passé ? La fonction 'RtlMoveMemory' de la DLL kernel32 a provoqué une erreur d'exécution.
Merci !![]()
Partager