vb.net 2003
I 'am running a routine.
A form opens up
Loads Files into combo box from a dir
I delete the file.
and then copy new files back into folder
This is the same code I'am using to load the combo box when the form opens.
Problem:
Combo box is not resetting correctly and showing me the new files I have copied
back into the folder...
' code=========== =
Private Sub btnRestart_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnRestart.Clic k
Dim ExcelFile As String
Dim FindFiles() As String = System.IO.Direc tory.GetFiles(" C:\Dm2007\Inbox \", "*.xls") ' filter only excel files *.xls
RestartText()
' Run Access Macros for restart
AccRestart()
For Each ExcelFile In FindFiles
' cboFileLoad.Ite ms.Add(ExcelFil e) 'all the dir and file name
cboFileLoad.Ite ms.Add(ExcelFil e.Substring(Exc elFile.LastInde xOf("\"c) + 1))
Next
cboFileLoad.Ref resh()
MsgBox("Process Steps Reset", MsgBoxStyle.Inf ormation, "Reset Example Tables")
End Sub
Other Routines:
Private Sub AccRestart()
Dim oAccess As New Microsoft.Offic e.Interop.Acces s.Application
'Start Access and open the database.
oAccess = CreateObject("A ccess.Applicati on")
oAccess.Visible = False
oAccess.OpenCur rentDatabase("C :\dm2007\ImpDat a.mdb", False)
'Run the macros.
oAccess.Run("Re set1")
'Clean-up: Quit Access without saving changes to the database.
oAccess.Quit()
oAccess = Nothing
'============== ==============
End Sub
Private Function RestartText()
' DELETE FILES First
' Do The Filing System stuff
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Rem oveSpecialTest. txt", "C:\Dm2007\Text FilesSamples\Re moveSpecialTest .txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Rep laceTest.txt", "C:\Dm2007\Text FilesSamples\Re placeTest.txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Str ipVowels.txt", "C:\Dm2007\Text FilesSamples\St ripVowels.txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Ven dNameTest.txt", "C:\Dm2007\Text FilesSamples\Ve ndNameTest.txt" , True)
System.IO.File. Copy("C:\Dm2007 \Original\Searc hReplaceTables. xls", "C:\Dm2007\Inbo x\SearchReplace Tables.xls", True)
End Function
Thanks
fordraiders
I 'am running a routine.
A form opens up
Loads Files into combo box from a dir
I delete the file.
and then copy new files back into folder
This is the same code I'am using to load the combo box when the form opens.
Problem:
Combo box is not resetting correctly and showing me the new files I have copied
back into the folder...
' code=========== =
Private Sub btnRestart_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnRestart.Clic k
Dim ExcelFile As String
Dim FindFiles() As String = System.IO.Direc tory.GetFiles(" C:\Dm2007\Inbox \", "*.xls") ' filter only excel files *.xls
RestartText()
' Run Access Macros for restart
AccRestart()
For Each ExcelFile In FindFiles
' cboFileLoad.Ite ms.Add(ExcelFil e) 'all the dir and file name
cboFileLoad.Ite ms.Add(ExcelFil e.Substring(Exc elFile.LastInde xOf("\"c) + 1))
Next
cboFileLoad.Ref resh()
MsgBox("Process Steps Reset", MsgBoxStyle.Inf ormation, "Reset Example Tables")
End Sub
Other Routines:
Private Sub AccRestart()
Dim oAccess As New Microsoft.Offic e.Interop.Acces s.Application
'Start Access and open the database.
oAccess = CreateObject("A ccess.Applicati on")
oAccess.Visible = False
oAccess.OpenCur rentDatabase("C :\dm2007\ImpDat a.mdb", False)
'Run the macros.
oAccess.Run("Re set1")
'Clean-up: Quit Access without saving changes to the database.
oAccess.Quit()
oAccess = Nothing
'============== ==============
End Sub
Private Function RestartText()
' DELETE FILES First
' Do The Filing System stuff
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Rem oveSpecialTest. txt", "C:\Dm2007\Text FilesSamples\Re moveSpecialTest .txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Rep laceTest.txt", "C:\Dm2007\Text FilesSamples\Re placeTest.txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Str ipVowels.txt", "C:\Dm2007\Text FilesSamples\St ripVowels.txt", True)
System.IO.File. Copy("C:\Dm2007 \TextFilesSampl es\Original\Ven dNameTest.txt", "C:\Dm2007\Text FilesSamples\Ve ndNameTest.txt" , True)
System.IO.File. Copy("C:\Dm2007 \Original\Searc hReplaceTables. xls", "C:\Dm2007\Inbo x\SearchReplace Tables.xls", True)
End Function
Thanks
fordraiders
Comment