|
本帖最后由 VBA万岁 于 2014-11-21 16:53 编辑
renahu 发表于 2014-11-21 12:20
我觉得第5句应改为:
\u6211\u89C9\u5F97\u7B2C5\u53E5\u5E94\u6539\u4E3A\uFF1A
关于字符串与其unicode码之间的互换,请参见如下代码:- Private Function Encode(strEncode As String) As String
- Dim i As Long
- Dim chrTmp As String
- Dim ByteLower As String
- Dim ByteUpper As String
- Dim strReturn As String
- For i = 1 To Len(strEncode)
- chrTmp$ = Mid(strEncode, i, 1)
- ByteLower$ = Hex$(AscB(MidB$(chrTmp$, 1, 1)))
- If Len(ByteLower$) = 1 Then ByteLower$ = "0" & ByteLower$
- ByteUpper$ = Hex$(AscB(MidB$(chrTmp$, 2, 1)))
- If Len(ByteUpper$) = 1 Then ByteUpper$ = "0" & ByteUpper$
- strReturn$ = strReturn$ & "\u" & ByteUpper$ & ByteLower$
- Next
- Encode = strReturn$
- End Function
- Sub 获取字符串unicode码()
- ActiveCell = "HTTP://www.apabi.com/ValidateCode.aspx我觉得第5句应改为:"
- MsgBox Encode(ActiveCell)
- ActiveCell.Offset(1) = Encode(ActiveCell)
- ActiveCell.Offset(1).Select
- End Sub
- Function unescape(strTobecoded As String) As String
- With CreateObject("msscriptcontrol.scriptcontrol")
- .Language = "JavaScript"
- unescape = .Eval("unescape('" & strTobecoded & "');")
- End With
- End Function
- Sub 根据unicode码返回字符串()
- MsgBox unescape(ActiveCell)
- ActiveCell.Offset(-1).Select
- End Sub
复制代码 |
|