2010-03-29 75 views
4

我在vb.net中有這個字符串。 我將不勝感激,如果你可以讓我知道我可以在雙引號將值用VB.net中的雙引號括起來

dim str as string="" 
str.Append("EmpID=" & empNo & " DeptID=" & deptID & "") 

我想被EmiID =「10」 DEPTID =「20」

回答

6

使用雙重雙引號來得到一個雙引號字符串中

str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """") 
+0

單*雙*報價,您的意思是,對不對? ;-) – Prutswonder 2010-03-29 21:06:32

+0

@Prutswonder,正確更新 – JaredPar 2010-03-29 21:10:01

2

只需使用字符串的值請將這些值如雙雙引號:

dim str as string="" 
str.Append("EmpID=""" & empNo & """ DeptID=""" & deptID & """") 
2

使用ControlChars.Quote

dim str as string="" 
str.Append("EmpID=" & cControlChars.Quote & empNo & ControlChars.Quote & " DeptID=" & ControlChars.Quote & deptID & ControlChars.Quote) 
3

ControlChars.Quote是很好用:)

暗淡metatransferString作爲字符串= 「」

0

我知道這是一個很老的問題。但我用這種方式

str.Append(String.Format("EmpID={0}{1}{0} DeptID={0}{2}{0}", Chr(34), empNo, deptID)) 

如果EMPNO = 10 DEPTID = 20,這會給EMPID = 「10」 DEPTID = 「20」

相關問題