VB編程:"&"替換"+"

"&"替換"+"
在很多人的程式語言中,用“+”來連線字元串,這樣容易導致歧義。良好的習慣是用“&”來連線字元串.
不正確:
dim smessage as string
smessage = "1" + "2"
正確:
dim smessage as string
smessage = "1" & "2"
注意:"&"的後面有個空格
 

在簡單的選擇條件情況下,使用iif()函式
繁瑣的代碼:
if nnum = 0 then
sname = "sancy"
else
sname = "xu"
end if
簡單的代碼:
sname=iif(nnum=0,"sancy","xu")