Advertisement
Guest User

Untitled

a guest
Dec 21st, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Function Compare(ByVal str1 As String, ByVal str2 As String) As Double
  2. Dim count As Integer = If(str1.Length > str2.Length, str1.Length, str2.Length)
  3. Dim hits As Integer = 0
  4. Dim i, j As Integer : i = 0 : j = 0
  5. For i = 0 To str1.Length - 1
  6. If str1.Chars(i) = " " Then i += 1 : j = str2.IndexOf(" "c, j) + 1 : hits += 1
  7. While j < str2.Length AndAlso str2.Chars(j) <> " "c
  8. If str1.Chars(i) = str2.Chars(j) Then
  9. hits += 1
  10. j += 1
  11. Exit While
  12. Else
  13. j += 1
  14. End If
  15. End While
  16. If Not (j < str2.Length AndAlso str2.Chars(j) <> " "c) Then
  17. j -= 1
  18. End If
  19. Next
  20. Return Math.Round((hits / count), 2)
  21. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement