Dim moScript As MSScriptControl.ScriptControl
Set moScript = New MSScriptControl.ScriptControl
moscript.language="JavaScript" 'or "VBScript"
msgbox moScript.Eval("escape('a')")
Dim moScript As MSScriptControl.ScriptControl
Set moScript = New MSScriptControl.ScriptControl
moscript.language="JavaScript" 'or "VBScript"
msgbox moScript.Eval("escape('a')")
Option Explicit
Private Const MAX_PATH As Long = 260
Private Const ERROR_SUCCESS As Long = 0
Private Const URL_DONT_ESCAPE_EXTRA_INFO As Long = &H2000000
'Don't convert the # or ? character, or any characters following them in the string.
Private Const URL_ESCAPE_SPACES_ONLY As Long = &H4000000
'Only escape space characters. This flag cannot be combined with URL_ESCAPE_PERCENT or URL_ESCAPE_SEGMENT_ONLY
Private Const URL_ESCAPE_SEGMENT_ONLY As Long = &H2000
'Escape the sections following the server component, but not the extra information sections following a # or ? character.
Private Const URL_ESCAPE_PERCENT As Long = &H1000
'Escape the % character. By default, this character is not escaped
Private Const URL_UNESCAPE_INPLACE As Long = &H100000
'Use pszURL to return the converted string instead of pszUnescaped.
Private Const URL_INTERNAL_PATH As Long = &H800000
Private Declare Function UrlEscape Lib "shlwapi" Alias "UrlEscapeA" (ByVal pszURL As String, ByVal pszEscaped As String, pcchEscaped As Long, ByVal dwFlags As Long) As Long
Private Declare Function UrlUnescape Lib "shlwapi" Alias "UrlUnescapeA" (ByVal pszURL As String, ByVal pszUnescaped As String, pcchUnescaped As Long, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
Text1.Text = "http://vbnote.cjb.net/s o m t t e x t h e r e.html"
Text2.Text = ""
Text3.Text = ""
Command1.Caption = "去除空白"
Command2.Caption = "回復空白"
End Sub
Private Sub Command1_Click()
Dim SUrl As String, dwSize As Long
Dim sUrlEsc As String
Private Sub Command2_Click()
Dim sUrlEsc As String, dwSize As Long
Dim sUrlUnEsc As String
sUrlEsc = Text2.Text
sUrlUnEsc = Space(MAX_PATH)
dwSize = Len(sUrlUnEsc)
UrlUnescape sUrlEsc, sUrlUnEsc, dwSize, URL_INTERNAL_PATH
sUrlUnEsc = Left(sUrlUnEsc, dwSize)
Text3.Text = sUrlUnEsc
End Sub