0

我在附加文件时遇到加载进度条的问题。我希望进度条在完成扫描附件文件之前一直工作。问题是当我附加文件并开始扫描时,我的进度条可能工作 3-5 秒,我希望进度条会一直持续到文件完成扫描。

这是我的 opendialog 代码:

 Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        strm = OpenFileDialog1.OpenFile()
        filename = OpenFileDialog1.FileName
        OpenFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"
        TextBox1.Text = filename
        If Not (strm Is Nothing) Then
            strm.Close()
        End If
 End Sub

浏览按钮代码:

 Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.Title = "Please Select a File"
        OpenFileDialog1.InitialDirectory = "C:temp"
        OpenFileDialog1.Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"
        OpenFileDialog1.ShowDialog()
 End Sub

生成附件的代码:

 Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdIntralinks.Click
    conn.Open()
       Timer1.Enabled = True 
       Timer1.Interval = 50 
       ProgressBar1.Value = 0
conn.close()

timer1_tick 的代码:

   Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Static TikTok As Integer
        TikTok = TikTok + 1
        ProgressBar1.Value = TikTok
        If ProgressBar1.Value = ProgressBar1.Maximum Then
            Timer1.Enabled = False
            TikTok = 0
        End If
    End Sub
4

1 回答 1

0

看看它是否有效:

Private Sub Timer1_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Static TikTok As Integer
    TikTok = TikTok + 1
    ProgressBar1.Value = TikTok
    If ProgressBar1.Value = ProgressBar1.Maximum Then
        Timer1.Enabled = False
        TikTok = 0
    End If
   Application.DoEvents()
End Sub

顺便说一句,您是否已经在 if 子句中设置了断点,以查看 progressbar.maximum 是否在预期之前达到最大值?青色

于 2013-02-06T08:53:28.847 回答