我希望我的 Visual Basic 应用程序运行一个带有进度条的闪屏,然后检查文件是否存在,但我遇到了一个问题,因为一旦我启动并且闪屏出现,文件检查器就会启动,但我希望它检查何时加载 form1
而不是启动画面。这是我的代码,我可以使用一个建议:
启动画面:
Public NotInheritable Class SplashScreen1
'TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab
' of the Project Designer ("Properties" under the "Project" menu).
Private Sub Splashscreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Dte As DateTime = DateTime.Now
Label2.Text = FormatDateTime(Dte, DateFormat.LongDate)
Timer1.Start()
Timer2.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ProgressBar1.Value = ProgressBar1.Maximum Then
Form1.Show()
Me.Close()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
ProgressBar1.PerformStep()
End Sub
End Class
表格 1:
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If My.Computer.FileSystem.FileExists(Application.StartupPath & "/read me.txt") Then
MsgBox("file found")
Else
MsgBox("not found")
End If
End Sub
End Class
最佳答案
尝试将您的 Form1 代码从 Load 事件移动到 Shown 事件。在表单对用户可见之前运行加载,根据我的理解,这不是您想要的。
关于.net - Visual basic 2010 检查表单加载时文件是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14200744/