开发者

List of characters in VBScript that require escape characters

开发者 https://www.devze.com 2023-02-09 21:55 出处:网络
I just learned that $ requires an escape character.What other special characters are there in VBScript?

I just learned that $ requires an escape character. What other special characters are there in VBScript?

Also is there a boolean function where I c开发者_运维问答an find out if a character is a special character?


Huh? WScript.Echo "$" outputs $ without any escaping. The only special character in a VBScript string literal is the double quote (use two in a row for a literal double quote within a string).


You have to escape bigmoney when using it in VBScript regular expressions, but that is a very specific case. You cannot use it as you are used to in some BASIC flavours, VBA or VB to assign the String primitive to a variable. (like

10 FOR I = 1024 TO 1063
20 A$ = A$ + CHR$(PEEK(I))
30 NEXT I
40 ? A$;
50 A$ = ""
60 GOTO 10

for the C64 or

Dim i, original$, final$
original$ = "Hello World!"
' Premature optimization rules! xxx$ functions are faster than xxx functions!
final$ = Left$(original$, 3) & Chr$(112) & Chr$(32) & Chr$(109) & Mid$(original$, 2, 1) & Right$(original$, 7)
MsgBox final$

In good ol' VB6)

Just eliminate the $ in the latter example, you don't need them.

If you really, really, really want to use the $ in routine or variable naming, you can always use the brackets like:

Sub [Wow! does thi$ really works? I'm a 1337 h4x0rz!]
    MsgBox "Yes it does!"
End Sub
[Wow! does thi$ really works? I'm a 1337 h4x0rz!]

Edit;
Extra-Free-Bonus: A specialcharacter recognition function:

Public Function isSpecialCharacter(byVal myChar)
    isSpecialCharacter = (myChar="""")
End Function
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号