'convert a map to a querystring
Sub Map2QueryString(sm As Map) As String
' convert a map to a querystring string
Dim SU As StringUtils
Dim iCnt As Int
Dim iTot As Int
Dim sb As StringBuilder
Dim mValue As String
sb.Initialize
' get size of map
iTot = sm.Size - 1
iCnt = 0
For Each mKey As String In sm.Keys
mValue = sm.Getdefault(mKey,"")
mValue = mValue.trim
mValue = SU.EncodeUrl(mValue, "UTF8")
mKey = mKey.Trim
If mKey.EndsWith("=") = False Then mKey = mKey & "="
sb.Append(mKey).Append(mValue)
If iCnt < iTot Then sb.Append("&")
iCnt = iCnt + 1
Next
Return sb.ToString
End Sub