Message Box in VB.Net


MessageBox in VB.Net


you can write one of this two commands to show a message box

MessageBox.Show("hello")   

MsgBox("hello")

                      
                              and you can change its tittle like this:

MessageBox.Show("hello", "your tittle")



I.Box Signs

1.the first is for info messages


and here is the code

MessageBox.Show("hello", "your tittle",MessageBoxButtons.OK,MessageBoxIcon.Question)


2.this one for error message

the code is 

 MessageBox.Show("hello", "your tittle", MessageBoxButtons.OK, MessageBoxIcon.Error)



3.and this one for Exclamation message


and you code it like this

MessageBox.Show("hello", "your tittle", MessageBoxButtons.OK, MessageBoxIcon.Exclamation



4.and this one for question message

and the code is:

   MessageBox.Show("hello", "your tittle",MessageBoxButtons.OK,MessageBoxIcon.Question)


and now we finish with the signs 


II. 
now we go to box buttons

1. ok & cancel

code:

 MessageBox.Show("hello", "your tittle", MessageBoxButtons.OKCancel)


2.yes & no
code:

  MessageBox.Show("hello", "your tittle", MessageBoxButtons.YesNo)



3.Retry & cancel
code:

 MessageBox.Show("hello", "your tittle",MessageBoxButtons.RetryCancel)



4.abort & retry & agnore
code:

  MessageBox.Show("hello","your tittle",MessageBoxButtons.AbortRetryIgnore)



5.yes & no & cancel
code:

MessageBox.Show("hello", "your tittle", MessageBoxButtons.YesNoCancel)




III. the method of programming the Message box in VB.NET





IV.  How to get off to a new line

u
sing (vbnewline)
code:

    MessageBox.Show("hello" & vbNewLine & "Welcome")

V. An example in messageBox 

How to put a condition with MessageBox , meaning if you click on button (yes) the programm will switches off, and if you click the button (no) the programm will not switches of, as follows:

code:

 Select Case MessageBox.Show("do you want to close the programme", _
        "Exit", MessageBoxButtons.YesNo)
            Case DialogResult.Yes
                MsgBox("YES")
            Case DialogResult.No
                MsgBox("NO")    
 End Select
-----------------------------  
thanks for visit the site, leave a comment fallow us on facebook and twitter for more


Comments