2013-02-24 79 views
0

我有一個msgbox在vb.net和其他語句..... 我想傳遞一個字符串值來顯示字符串和消息文本像下面一樣 -如何傳遞一個字符串值在一個msgbox vb.net

Normal 

    msgbox("student is not eligible for the company") 

TO 

    MSGBOX([string]"is not eligible for the company") 

RESULT 

    Anthony is not eligible for the company 

任何解決此問題..........?

回答

4
dim StudentName as string 
StudentName = "Student" 

If (specificStudent) Then 
    StudentName = "SpecificName" 
End If 

MsgBox(StudentName + " is not eligible") 

編輯:另外,你可以使用string.Format這裏

dim StudentName as string 
StudentName = "Student" 

If (specificStudent) Then 
    StudentName = "SpecificName" 
End If 

'I suppose string.format works same way in vb.net, as it does in c#  
MsgBox(String.Format("{0} is not eligible", StudentName)) 
+0

did'nt需要的情況下,如果你的位工作的String.Format由於 – CrashOverride 2013-02-24 19:08:37

+0

@ user1897472:已添加到舉一個例子。 – shahkalpesh 2013-02-24 19:29:20