Programming Reference Manual
 
Syntax
 
Result = URLEncode(Url[, SpacePlus])
 
Description
Converts an html-link into in a valid escaped URL, optionally converting "+" and " " into valid characters.
 
For new development that must interoperate with modern web platforms expecting UTF-8 percent-encoding (such as REST APIs and JavaScript encodeURIComponent output), the toURL method of the StringClass is the recommended alternative.
 
Parameter
Description
URL
The specified html-link to be formatted into a valid URL.
SpacePlus
Optional, Boolean. If True, the "+" and space characters are converted in html-encoded strings:
"+" -> %"2B"
" " -> "+"
See Also
Example
Sub Main
Dim sQuery$
Dim sURL$
 
' Build a redirect URL with an escaped query string.
sQuery$ = "name=Müller & Co.&city=Köln"
sURL$ = "https://api.example.com/lookup?" & URLEncode(sQuery$)
 
Debug.Print sURL$
End Sub