Help modifing

  • 13 years ago
    I came up with this code to load the file names into a combo box but i get the file extenstion as well as a few other parts can anyone help me modify this code.
    My outcome is :
    .
    ..
    test.tps

    "." and ".." being the directries i believe and test.tps being the file. I want to remove .tps and the "." and ".." Thanks

    Dim sPath As String
    Dim sTmp As String
    sPath = App.Path & "\Students\"

        sTmp = Dir(sPath, vbDirectory)
        Do While sTmp <> ""
                CmbSelect.AddItem sTmp
            sTmp = Dir
        Loop

















  • 13 years ago

    I think it should be something like this:

    Dim sPath As String
    Dim sTmp As String
    sPath = App.Path & "\Students\*.*"
    sTmp = Dir(sPath, vbNormal)
    While sTmp <> ""
       If Left(sTmp,1) <> "." Then
          sTmp = Left(sTmp, InStr(sTmp, ".") - 1)
          cmbSelect.AddItem sTmp
          sTmp = Dir
    Wend








    Regards,

    Erwin

  • 13 years ago

    Hi,

    Just do not forget the "End If" before the "Wend"

  • 13 years ago

    Oops...

    Thanks for catching that one.  I obviously didn't do that code in VB, but straight on the site.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debuggers don't remove bugs. They only show them in slow motion.”