Showing posts with label UnEscape. Show all posts
Showing posts with label UnEscape. Show all posts

Monday, January 03, 2011

[VB6] Using VBScript's Escape and UnEscape (Take 2)

It's been pointed out to me recently that Escape() doesn't handle embedded quotes and embedded newlines. This is the fix.

I'm using JScript rather than VBScript, so that I can use the String object's fromCharCode() method. I parse the input string, convert the characters to a list of their numeric equivalents for passing to fromCharCode() and then store the result in a JScript variable which is then passed to escape().

Thanks to Anonymous and anjali kalkarni for pointing out the problem.


© Bruce M. Axtens, 2011

Thursday, July 02, 2009

[VB6] Using VBScript's Escape and UnEscape

Something again from an answer I gave on StackOverflow. This one demonstrates how to use MSScriptControl.ScriptControl to make VBScript's Escape and Unescape functions available to the VB6 programmer.

The best thing would be add MSSCRIPT.OCX to the project, but for the sake of demonstration, I'll use CreateObject instead.


Using the code is easy.


It's that simple. And the technique can be used to get at other VBScript functionality. In fact, .Language can have values other than "VBScript", making it possible to interface to any language with a Windows Scripting Host presence.

© Copyright Bruce M. Axtens, 2009