要由A表單開啟B表單, 在A表單上設計一個button, 按下後會開啟B表單並同時關閉A表單
Public Class Home
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Close()
FanNoise.Show()
End Sub
End Class
'------------------------------------------
卻只會關閉A表單不會開啟B表單, 改成下列這樣
'------------------------------------------
Public Class Home
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
FanNoise.Show()
End Sub
End Class
'------------------------------------------
開啟B表單卻不會關閉A表單,該如何才能開啟B表單並同時關閉A表單?作者: mark15jill 時間: 2017-1-22 13:55
要由A表單開啟B表單, 在A表單上設計一個button, 按下後會開啟B表單並同時關閉A表單
Public Class Home
...
acdx 發表於 2016-12-2 15:06
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim fanWin = New FanNoise()
fanWin.ShowDialog() '當執行到此行,會彈出FanNoise窗口,而使目前窗口暫時失去作用,你點它也沒有用,除非離開FanNoise窗口。主窗口才會恢復其作用
MessageBox.Show("回到主窗口") '離開FanNoise窗口後才會執行這一行