Combo box Not showing data after routine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fordraiders
    New Member
    • Jan 2007
    • 3

    Combo box Not showing data after routine

    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
  • jaketrimble
    New Member
    • Jan 2007
    • 14

    #2
    I am not exactly sure, but you have declard ExcelFile as a string, but it has no assigned value.

    When you move to your "for each" statement ExcelFile is still empty.

    rough example:

    dim xlsFile as File or Object 'im not sure

    for each xlsFile in system.io.direc tory.getfiles(" blah","*xls")

    combobox.items. add(xlsfile)

    next xlsFile

    Comment

    • fordraiders
      New Member
      • Jan 2007
      • 3

      #3
      Thanks
      Wow! It worked..!
      However, In the combobox I do not need to see the dir reference..
      It shows:

      c:\dm2007\inbox \<filename>.xl s
      I just need to see
      <filename>.xl s

      Appreciate the help ! Very very much.!

      Comment

      • jaketrimble
        New Member
        • Jan 2007
        • 14

        #4
        Originally posted by fordraiders
        Thanks
        Wow! It worked..!
        However, In the combobox I do not need to see the dir reference..
        It shows:

        c:\dm2007\inbox \<filename>.xl s
        I just need to see
        <filename>.xl s

        Appreciate the help ! Very very much.!
        you should be able to do this...

        for each ...

        combobox.items. add(System.IO.P ath.GetFileName (xlsFile))

        next...

        Comment

        Working...