Programming, technology, and CRM – from a Belgian programmer exiled to Missouri
  • rss
  • Home
  • Soft Gallery
    • autosvnbackup.sh
    • VBScript Snippets
  • Contact Me
  • Welcome

VBScript Snippets

Handy VBScript snippets to copy/paste.

General Use

URLEncode

Apparently there is no URLEncode in the VBScript default library. Go figure. So this escape unsafe values for inclusion in a URL or POST data. This only handles the most common cases though.

Function URLEncode(s)
    s = Replace(s, "%", "%25")
    s = Replace(s, "$", "%24")
    s = Replace(s, "&", "%26")
    s = Replace(s, "+", "%2B")
    s = Replace(s, ",", "%2C")
    s = Replace(s, "/", "%2F")
    s = Replace(s, ":", "%3A")
    s = Replace(s, ";", "%3B")
    s = Replace(s, "=", "%3D")
    s = Replace(s, "?", "%3F")
    s = Replace(s, "@", "%40")
    s = Replace(s, " ", "%20")
    URLEncode = s
End Function

ArrayPush

Good old array push – will push a single value onto an array.
Hard to believe the things we take for granted in more modern languages and take a good 10 lines in VBScript.

Sub ArrayPush(ByRef a, v)
    If IsEmpty(a) Then
        Redim a(0)
    Else
        Redim Preserve a(UBound(a) + 1)
    End If
    If IsObject(v) Then
        Set a(UBound(a)) = v
    Else
        a(UBound(a)) = v
    End If
End Sub

SalesLogix

Windows/AD Automation

Comments rss
Comments rss
Trackback
Trackback

Leave a Reply

Click here to cancel reply.

Categories

  • Dojo (1)
  • Experiments (4)
  • Force.com (2)
  • Interesting (1)
  • Javascript (3)
  • MSCRM (1)
  • Programming (63)
  • Rant (3)
  • Saleslogix (41)
  • Tricks (8)
  • Uncategorized (32)

Post History

  • 2011
    • January (3)
    • February (2)
    • March (1)
  • 2010
    • January (3)
    • March (3)
    • April (2)
    • August (2)
    • October (4)
    • November (1)
    • December (2)
  • 2009
    • March (2)
    • April (1)
    • May (3)
    • June (3)
    • July (1)
    • September (3)
    • October (2)
    • December (5)
  • 2008
    • January (9)
    • February (4)
    • March (9)
    • April (1)
    • May (5)
    • June (8)
    • July (1)
    • August (2)
    • September (1)
    • November (1)
    • December (3)
  • 2007
    • January (3)
    • February (7)
    • March (1)
    • April (3)
    • May (6)
    • June (2)
    • July (1)
    • August (2)
    • September (5)
    • October (3)
    • November (5)
    • December (4)
  • 2006
    • January (2)
    • September (1)
    • November (3)
    • December (4)
  • 2005
    • April (1)

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox