2013-01-07 51 views
2

我想讓我的Visual Basic應用程序運行帶有進度條的啓動畫面,然後檢查文件是否存在,但自從啓動以來,我遇到了問題,啓動屏幕顯示文件檢查器啓動,但我希望它檢查何時加載而不是啓動屏幕form1。這裏是我的代碼,我可以用一個忠告:Visual basic 2010檢查文件是否存在於表單加載

閃屏:

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 
+1

當你需要* *之一,50毫秒是不夠的,只有使用閃屏。同樣,只有當你知道需要多長時間時才使用進度條。你不知道。 –

回答

4

嘗試從Load事件到移動你的Form1的代碼顯示的事件。在表單對用戶可見之前運行加載,這不是我所理解的。

+0

這樣做的伎倆,我只是改變Handles Me.load來處理Me.Shown。 謝謝傑森! – user1955680

0

您的timer1_tick事件正在導致此問題。 Timer1在啓動畫面加載時啓用,並且取決於在form1加載之前它可能永遠不會顯示的timer_interval。你想讓用戶在這段時間看到什麼嗎?

進度條意味着正在發生一個或一組操作。你有什麼需要進度條?如果你想要發生事情的幻想,請確保你的timer1間隔大於你的timer2間隔,因爲timer1控制了在加載form1之前splashscreen是可見的多長時間。

0
If ProgressBar1.Value = ProgressBar1.Maximum Then 
     Form1.Show() 
     Me.Close() 
End If 

變化:

If ProgressBar1.Value = ProgressBar1.Maximum Then 
     Form1.Visible = True 
     Me.Visible = False 
End If