Hey guys,
I'm a novice to programming and use it mainly to make my job easier.
I got a problem with making my progressbar work on a form. When I only make the timer and progressbar everything runs fine, but when I try to implement it in the code, it won't work and just hangs untill the cop is done
Here is the code:
Imports System
Imports System.IO
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Dim DataDir As String
Dim DestDir As String = (My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\Lotus\Notes\Data")
Dim FoundFile As String
Public Shared a As String
Public Shared b As String
Public Shared swLocation As String = (Environment.GetEnvironmentVariable("WINDIR") & "\Temp\NotesDataCopier.log")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'turn on timer for ProgressBar
Timer1.Enabled = True
'Look for the files and write them into FoundFile
Me.Hide()
fbdBrowse.ShowDialog()
If Windows.Forms.DialogResult.OK Then
DataDir = fbdBrowse.SelectedPath
End If
'show and hide controls and form
pbCopy.Visible = True
Button1.Visible = False
Me.Show()
Try
For Each FoundFile In My.Computer.FileSystem.GetFiles _
(DataDir, FileIO.SearchOption.SearchTopLevelOnly, "*.nsf")
'Copy the files to the Dest. Dir with no prompt for overwrite, it just does the dirty job
File.Copy(FoundFile, DestDir & FoundFile.Replace(DataDir, ""), True)
'Do some counting of the nsf files
a = a + 1
Next
For Each FoundFile In My.Computer.FileSystem.GetFiles _
(DataDir, FileIO.SearchOption.SearchTopLevelOnly, "*.ID")
'Copy the files to the Dest. Dir with no prompt for overwrite, it just does the dirty job
File.Copy(FoundFile, DestDir & FoundFile.Replace(DataDir, ""), True)
'Do some counting of the id files
b = b + 1
Call LogIt.Main()
Next
Catch c As Exception
'Catch the error and display it.
MsgBox("AnError Occurred: " & c.ToString(), MsgBoxStyle.Critical = MsgBoxStyle.DefaultButton1, "Notes Data Copier")
Call LogIt.Main()
End
End Try
MsgBox("Data Copy Done", MsgBoxStyle.Information, "Notes Data Copier")
End
End Sub
Class LogIt
Public Shared Sub Main()
' Create an instance of StreamWriter to write text to a file.
Using sw As StreamWriter = New StreamWriter(swLocation)
' Add some text to the file.Arbitrary objects can also be written to the file.
sw.Write("Copied: " & a & " NSF and " & b & " ID Files sucessfully. @ Date: " & DateTime.Now)
sw.Close()
End Using
End Sub
End Class
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'enable Timer for Progressbar and show it on the form
pbCopy.Value += 1
If pbCopy.Value = pbCopy.Maximum Then
Timer1.Enabled = False
End If
End Sub
End Class
what do I miss here?
thanks for the effort
Greetzzz,
CornElvis
I'm a novice to programming and use it mainly to make my job easier.
I got a problem with making my progressbar work on a form. When I only make the timer and progressbar everything runs fine, but when I try to implement it in the code, it won't work and just hangs untill the cop is done
Here is the code:
Imports System
Imports System.IO
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Dim DataDir As String
Dim DestDir As String = (My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\Lotus\Notes\Data")
Dim FoundFile As String
Public Shared a As String
Public Shared b As String
Public Shared swLocation As String = (Environment.GetEnvironmentVariable("WINDIR") & "\Temp\NotesDataCopier.log")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'turn on timer for ProgressBar
Timer1.Enabled = True
'Look for the files and write them into FoundFile
Me.Hide()
fbdBrowse.ShowDialog()
If Windows.Forms.DialogResult.OK Then
DataDir = fbdBrowse.SelectedPath
End If
'show and hide controls and form
pbCopy.Visible = True
Button1.Visible = False
Me.Show()
Try
For Each FoundFile In My.Computer.FileSystem.GetFiles _
(DataDir, FileIO.SearchOption.SearchTopLevelOnly, "*.nsf")
'Copy the files to the Dest. Dir with no prompt for overwrite, it just does the dirty job
File.Copy(FoundFile, DestDir & FoundFile.Replace(DataDir, ""), True)
'Do some counting of the nsf files
a = a + 1
Next
For Each FoundFile In My.Computer.FileSystem.GetFiles _
(DataDir, FileIO.SearchOption.SearchTopLevelOnly, "*.ID")
'Copy the files to the Dest. Dir with no prompt for overwrite, it just does the dirty job
File.Copy(FoundFile, DestDir & FoundFile.Replace(DataDir, ""), True)
'Do some counting of the id files
b = b + 1
Call LogIt.Main()
Next
Catch c As Exception
'Catch the error and display it.
MsgBox("AnError Occurred: " & c.ToString(), MsgBoxStyle.Critical = MsgBoxStyle.DefaultButton1, "Notes Data Copier")
Call LogIt.Main()
End
End Try
MsgBox("Data Copy Done", MsgBoxStyle.Information, "Notes Data Copier")
End
End Sub
Class LogIt
Public Shared Sub Main()
' Create an instance of StreamWriter to write text to a file.
Using sw As StreamWriter = New StreamWriter(swLocation)
' Add some text to the file.Arbitrary objects can also be written to the file.
sw.Write("Copied: " & a & " NSF and " & b & " ID Files sucessfully. @ Date: " & DateTime.Now)
sw.Close()
End Using
End Sub
End Class
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'enable Timer for Progressbar and show it on the form
pbCopy.Value += 1
If pbCopy.Value = pbCopy.Maximum Then
Timer1.Enabled = False
End If
End Sub
End Class
what do I miss here?
thanks for the effort
Greetzzz,
CornElvis
Laatst bewerkt: