1、Form1中的代码:

Public Class Form1
Inherits System.Windows.Forms.Form
'创建Form2的一个新的实例
Dim Frm2 As New Form2()

Public Function Instance2(ByVal frm As Form2)
Frm2 = frm
End Function

Private Sub BtnShowFrm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnShowFrm2.Click
'以下语句保证在Form2以及其他窗体中访问Form1时,
'都将得到Form1的同一个窗体实例。
Frm2.Instance(Me)
Frm2.Show()
Me.Hide()
End Sub

End Class

  2、Form2中的代码:

Public Class Form2
 Inherits System.Windows.Forms.Form
 Dim frm1 As Form1
 '借助一个新增的Instance属性来生成窗体frm1的实例
 Public Function Instance(ByVal frm As Form1)
  frm1 = frm
 End Function

 Private Sub BtnShowFrm1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)    Handles BtnShowFrm1.Click
  Me.Hide()
  frm1.Show()
 End Sub

 Private Sub Form2_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles  MyBase.Closed
  '如果Form2被关闭,则设置Form1的按钮BtnShowFrm2不可用。
  frm1.BtnShowFrm2.Enabled = False
  frm1.Show()
 End Sub
End Class


[em77][em77][em77][em77][em77][em77][em77]
[img]C:\Documents and Settings\W8589000\ASPNET\My Documents\My Pictures\1.jpg[/img]