What is the difference between MsgBox() and MessageBox.show() in vb.net
I wanted to display a title on my message box i tried this code
MsgBox开发者_如何学Python('Cannot Conncet to the db',"Conncetion Error!")
but it gives me a error, so i read on some blog they included 1 as an addtional parameter inside the msgBox
MsgBox('Cannot Conncet to the db',1,"Conncetion Error!")
.
why that addtional parameter is needed.no difference, it is just to be somehow familiar with vb 6 and earlier
You need the three parameters because the VB.NET MsgBox function takes either one parameter (Prompt) or three parameters (Prompt, Buttons, Title).
See MsgBox Function (Visual Basic) on MSDN for details on the parameters and a number of examples.
To display just the title you might write the following (notice the empty Buttons
parameter):
MsgBox("Cannot Connect to the db", ,"Connection Error!")
I'll also add here that you might want to Or
the various MsgBoxStyle
options for your Buttons parameter; doing so makes your code a bit easier to read over using integer values. The link has examples.
精彩评论