randem: check your function's values with the test strings I provided. It gives odd results.

KEYWORD = "abcdefghijklmnopqrstuvwxyzåäö"
TEST = String$(100000, "X") & KEYWORD


Returns: -31071 (should be 100001)

KEYWORD = "abcdefghijklmnopqrstuvwxyzåäö"
TEST = KEYWORD & String$(100000, "X")


Returns: 1 (correct)


You can also optimize your function by about 25% (with the big string I used) if you switch ByVal to ByRef in strings. ByVal causes strings to be copied, which isn't so nice.