Sample code for 30+ languages & platforms
VB.NET

URL Encoding and Decoding

See more Encryption Examples

Demonstrates URL encoding and decoding.

Chilkat VB.NET Downloads

VB.NET
Dim success As Boolean = False

' To URL encoding a string:
Dim s As String = "Why a > b?"

Dim sb As New Chilkat.StringBuilder
success = sb.Append(s)

' URL encode the string.
sb.Encode("url","utf-8")

' Show the URL encoded string:
Dim sEncoded As String = sb.GetAsString()
Debug.WriteLine(sEncoded)

' The result is:  Why%20a%20%3E%20b%3F

' If you prefer "+" instead of "%20" for SPACE chars:
Dim numReplaced As Integer = sb.Replace("%20","+")
Debug.WriteLine(sb.GetAsString())

' Output is:   Why+a+%3E+b%3F

' To decode:
sb.Decode("url","utf-8")
Debug.WriteLine(sb.GetAsString())

' Result is: Why a > b?