我在附加文件时遇到加载进度条的问题。我希望进度条工作,直到它完成扫描附件文件。问题是当我附加文件并开始扫描时,我的进度条可能需要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
答案 0 :(得分: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是否在预期之前达到了它的最大值?
CYA