2

将逗号 ("") 插入字符串 Visual Basic

Dim str As String

str = "*.doc" & "," & "*.docx"

我想要文本框显示"*.doc" & "," & "*.docx"

4

5 回答 5

4

写出你想要的字符串:

str = "*.doc" & "," & "*.docx"

加倍引号以逃避它们:

str = ""*.doc"" & "","" & ""*.docx""

然后引用整个字符串:

str = """*.doc"" & "","" & ""*.docx"""

?str
"*.doc" & "," & "*.docx"
于 2012-08-09T09:46:01.783 回答
2

根本不清楚你要什么。如果你这样做,结果字符串将是*.doc,*.docx. 如果你想要引号(引号),你会做这样的事情:

str = Chr$(34) & "*.doc" & Chr$(34) & "," & Chr$(34) & "*.docx" & Chr$(34)

那会产生类似的东西

"*.doc","*.docx"

这是你想要的?如果没有,请告诉我们您要完成的工作,我们可以为您提供帮助。

于 2012-08-09T08:17:42.033 回答
1

这对我有用,试试吧。

Dim str As String = """ * .doc"" & "","" & ""*.docx """
TextBox1.Text = str
于 2017-07-22T02:16:48.700 回答
0

我用一个消息框对此进行了测试,它对我来说效果很好。

Dim str As String = "*.doc" & "," & "*.docx"
textbox1.text = str
于 2017-06-09T09:52:55.697 回答
0

VB6代码:

Dim str As String
str = "*.doc" & "," & "*.docx"
Text1.Text = str

VB.net 代码:

Dim str As String
str = "*.doc" & "," & "*.docx"
TextBox1.Text = str

这两个都有效。

于 2017-08-23T22:36:12.157 回答