应该是这样:
Public Class frmLogin
Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
Dim frmMain as new Form2
frmMain.Show()
Me.Finalize()
End Sub
End Class
没有那么麻烦,用下面这个程序段(vb):
在登录frmLogin窗体中:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Me.Close()
frmMain.Visible = True
End Sub
Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
frmMain.Visible = False
End Sub
在主窗体frmMain中:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
frmLogin.Show()
End Sub