Visualizzazione dei risultati da 1 a 3 su 3

Discussione: [VB] Errore su ReDim

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2008
    Messaggi
    173

    [VB] Errore su ReDim

    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

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,466

    Moderazione

    Originariamente inviato da mcfede88
    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.
    Indicare l'errore è fondamentale...
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    970
    A parte che le due frasi non ho mai programmato in VB e ma devo utilizzare una funzione che ho trovato in rete non vanno tanto d'accordo, il codice postato non ha solleva nessun errore.

    Sbagliare è umano, perseverare è diabolico.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.