Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Compare(ByVal str1 As String, ByVal str2 As String) As Double
- Dim count As Integer = If(str1.Length > str2.Length, str1.Length, str2.Length)
- Dim hits As Integer = 0
- Dim i, j As Integer : i = 0 : j = 0
- For i = 0 To str1.Length - 1
- If str1.Chars(i) = " " Then i += 1 : j = str2.IndexOf(" "c, j) + 1 : hits += 1
- While j < str2.Length AndAlso str2.Chars(j) <> " "c
- If str1.Chars(i) = str2.Chars(j) Then
- hits += 1
- j += 1
- Exit While
- Else
- j += 1
- End If
- End While
- If Not (j < str2.Length AndAlso str2.Chars(j) <> " "c) Then
- j -= 1
- End If
- Next
- Return Math.Round((hits / count), 2)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement