将逗号 ("") 插入字符串 Visual Basic
Dim str As String
str = "*.doc" & "," & "*.docx"
我想要文本框显示"*.doc" & "," & "*.docx"
写出你想要的字符串:
str = "*.doc" & "," & "*.docx"
加倍引号以逃避它们:
str = ""*.doc"" & "","" & ""*.docx""
然后引用整个字符串:
str = """*.doc"" & "","" & ""*.docx"""
?str
"*.doc" & "," & "*.docx"
根本不清楚你要什么。如果你这样做,结果字符串将是*.doc,*.docx
. 如果你想要引号(引号),你会做这样的事情:
str = Chr$(34) & "*.doc" & Chr$(34) & "," & Chr$(34) & "*.docx" & Chr$(34)
那会产生类似的东西
"*.doc","*.docx"
这是你想要的?如果没有,请告诉我们您要完成的工作,我们可以为您提供帮助。
这对我有用,试试吧。
Dim str As String = """ * .doc"" & "","" & ""*.docx """
TextBox1.Text = str
我用一个消息框对此进行了测试,它对我来说效果很好。
Dim str As String = "*.doc" & "," & "*.docx"
textbox1.text = str
VB6代码:
Dim str As String
str = "*.doc" & "," & "*.docx"
Text1.Text = str
VB.net 代码:
Dim str As String
str = "*.doc" & "," & "*.docx"
TextBox1.Text = str
这两个都有效。