开发者

How to make a variable that holds double qoutes

开发者 https://www.devze.com 2023-02-09 14:19 出处:网络
The question is simple, How do I define a variable which holds double quotes. when I try to define the variable like this

The question is simple, How do I define a variable which holds double quotes. when I try to define the variable like this

Dim s as S开发者_C百科tring = " " " ,

VS puts an extra quote like this

Dim s as String = """"


The extra " is used to escape the " character, so the sequence of two double-quotes ("") will show up as " when your string is displayed.


You actually have it correct with the 4 quotes, that is VBs way of escaping the quotes. So, for example:

        Dim oneDoubleQuote As String = """"
    Dim twoDoubleQuotes As String = """"""
    MessageBox.Show("One:" & oneDoubleQuote)
    MessageBox.Show("Two:" & twoDoubleQuotes)

The first message box has One:" and the second has Two:""

0

精彩评论

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