hi, guys here is my question:-

I've created an application for opening text files. there i got two forms.one contains the textbox where the contents of the file will be displayed. there is a button.clicking this will move me to another form which is displaying modally.in the second form i choose file and click open to load the contents. there is another button "Close". now if i click this button the modal form should close and the control should move to the first form. now here is where i've stucked. can anyone tell me how to close a modal form wihout clicking the 'X' in form title bar.

Plz reply soon...

Recommended Answers

All 9 Replies

Private Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Back.Click
Me.Close()
End Sub

use
Me.Close()

on the button click event

i've already used the suggested syntax.but it didn't work.

any other way plz...?

You could always try:
Application.Exit()

hi waynespangler i think this will close the entire application. but my question is to close only a single form and activate the parent.

regards
Shouvik

Sorry about that, I missed read it. I set up form1 with a button that has in the click event:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.ShowDialog()
    End Sub

In form2 I added a button with the following button click:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

And it works as expected. How is yours different compared to mine?

ok i've got it.
thanks for help all of you.

no me.close() not working it showing error

Hi vishnu varthan,

It's better to start a new thread and ask your question, because this thread is 4 years old and solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.