0
如果存在文件,並嘗試關閉或隱藏表單cnx並打開Form Product。 但有些事情是錯誤的,我不明白爲什麼這不工作。關閉Form1如果FileExists +打開Form2
Private Sub cnx_Load(sender As Object, e As EventArgs) Handles MyBase.Load
strFileName = "app.txt"
strBasePath = Application.StartupPath
If My.Computer.FileSystem.FileExists(strFileName) = True Then
Product.Show()
Me.Hide()
ElseIf My.Computer.FileSystem.FileExists(strFileName) = False Then
MessageBox.Show("File App.config is Missing! Create a new Database.",
"Something is Wrong!", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
謝謝。
你有7個問題,得到7個答案,但沒有接受。接受答案 - 和投票 - 幫助別人找到好帖子。 [旅遊]解釋SO如何工作。 – Plutonix
您不能在Load事件中隱藏()表單。 Load事件觸發是因爲您使用了Show()。您必須返回並找到創建表單的代碼,這就是If語句所屬的代碼。但是你可能想繼續這樣做,使用Close()來代替,然後使用Project> Properties> Application選項卡> Shutdown mode =關閉上一個窗體。 –
是的,這是....謝謝 – Jamyz