URLEncode for Large Strings

Category:
String Manipulation
Type:
Snippets
Difficulty:
Intermediate
Author:
Alexander Buschek

Version Compatibility: Visual Basic 6

More information:
ASP programmers know URLEncode very well. When I was looking for a snippet on the internet I found the regular apporach: run through every character in the string (for ... to len(txt)) and add either the original character or the replaced Code (%XX). This works fine for small strings. But when you want to URLEncode a large string (let's say 10,000 characters) this can take minutes due to the way MS implements string operations. So I took a different approach: I just replace all characters from chr(0) to chr(255) by their URL encoded expression. So this obviously makes sense if you have strings that are longer than let's say 255 characters. Any suggestions? And thanks to all contributers that helped me so much in the past!

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: