Я пытаюсь создать функцию в VBA, которая принимает 2 строки и порог (процент в десятичной форме) и возвращает значение true, если строки содержат более высокий процент тех же слов, чем порог. Вот код, который у меня есть до сих пор ...
Function isDup(tweet1 As String, tweet2 As String, threshold As Double) As Boolean
'Declare variables to store words from each tweet
Dim C1 As String
Dim C2 As String
'Use split function to split each tweet into single words. The " " is the delimiter, each space creates a new word
C1 = Split(tweet1, " ")
C2 = Split(tweet2, " ")
'Loop through each word from tweet1 and each word from tweet2
For i = LBound(C1) To UBound(C1)
For j = LBound(C2) To UBound(C2)
'Declare variable to store result from StrComp Function
Dim Cresult As Double
'Use StrComp Function to compare the current word from tweet1 to the current word from tweet2
Cresult = StrComp(i, j, vbTextCompare)
Next i
Next j
'Use If Then to return true if the tweets are more similar than the percentage given by the threshold
If Cresult > threshold Then
isDup = True
End Function
Я довольно новичок в VBA, поэтому есть некоторые ошибки, особенно я продолжаю сталкиваться с Ожидаемой: Ошибка массива. Любая помощь будет принята с благодарностью, спасибо!