hi all,

I am to pass two values from form f1 to form f2.i wrote a code on keypress event .It works good.But on loading of f2 i want to close f1.I wrote this on f1

Dim f As New frmattendance
f.Owner = Me
f.Show()
f.txttdays.Text = days
f.l2.Text = dtp.Text

on f2 load event

Me.Owner.Close()


Also tried this
Dim f As New frmmonth
f.Close()

If you are using vb 2005 then you don't need to dim a new form just load the second form. Just make sure that the "Shutdown" in the Projects is set to "When last form closes". If it is set to "When startup form closes" then as soon as you close form1 then the program ends.

frmattendance.txttdays.Text = days
        frmattendance.l2.Text = dtp.Text
        frmattendance.Show()
        Me.Close()

If you are using vb 2002 or 2003 try this. I don't have either but this should work.

Dim f As New frmattendance
        f.txttdays.Text = days
        f.l2.Text = dtp.Text
        f.Show()
        Me.Close()

Hi

I Have already tried the code as I am using VB.net 2003.But it was closing both the forms

Did you check the shutdown mode?

hi friends
I solved this problem.

I define
f.owner=me

then On f2 form closing

me.owner.close
me.close

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.