Can you give a small example on Modal and Modeless dialog boxes using VB.NET forms ?

Please let me know with sample code:

1.Modal Dialog Box
2.Modeless Dialog Box

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. MessageBox.Show( "I'm a modal box" )

2. Modal
Dim form as New Form2

3. Modeless
Dim form as New Form2

MessageBox is always modal. Form2 - is a windows form in your aplication.

good luck,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Naveen SwamyYash Infinite Solutions Private LimitedCommented:
modal dialog boxes have parent and once opened, cannot return to parent without closing the child form

modeless are those which are loosley coupled form which could be having assigned parents

        Dim objFrm As New Form
        objFrm.ShowDialog() '******MODAL*********
        MessageBox.Show("goodknowhow", "modalbox", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) '******MODAL*********

        objFrm.Show() '******MODELESS*********

Yes, in plain english.

If a form is opened as modeless, you can focus on other forms in you application while that on is open.
If it is opened "modal" , no other form can have focus until that form is closed. I.e the user cannot accidentily click on another part of your app and "loose" the form they were working on.

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

i'm just wondering how many more people will try to explain a difference between modal and modeless... No one so far tried plain Danish and it might be of help.
Hmm, If you weren't such an expert..(checks out profile for yurich). I'd think of a "come-back".
kishore_peddiAuthor Commented:


Thanks a lot for your explanation and code examples.

Jeees, why was it B??? what was possibly not enough???
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.