Ciao a tutti,
non sono un esperto in VB anzi non ho mai programmato in VB ma devo utilizzare una funzione che ho trovato in rete e mi sta dando errore su ReDim e sulle matrici.
La posto quì di seguito e grazie mille a tutti:
codice:Function Min3(a As Integer, b As Integer, c As Integer) As Integer Dim temp As Integer temp = a If b < temp Then temp = b If c < temp Then temp = c Min3 = temp End Function Public Function LevenshteinVB(a As String, b As String) As Integer Dim d() As Integer Dim i As Integer, j As Integer Dim c As Integer If Len(a) = 0 Then LevenshteinVB = Len(b) Exit Function End If If Len(b) = 0 Then LevenshteinVB = Len(a) Exit Function End If ReDim d(0 To Len(a), 0 To Len(b)) As Integer For i = 0 To Len(a) d(i, 0) = i Next i For j = 0 To Len(b) d(0, j) = j Next j For i = 1 To Len(a) For j = 1 To Len(b) If Mid$(a, i, 1) = Mid$(b, j, 1) Then c = 0 Else c = 1 End If d(i, j) = Min3(d(i - 1, j) + 1, d(i, j - 1) + 1, d(i - 1, j - 1) + c) Next j Next i LevenshteinVB = d(Len(a), Len(b)) End Function

Rispondi quotando
