The URL Encode function is wrong.
If the character code is less than 16 the hex code is only one symbol. It must be with a leading zero. Might be fixed this way:


If curChar < 16 Then
...