DirListNav



Const vbKeyEnterKey = 13

Public Function CompletePath(C As Control) As String
On Error Goto CPErr
If Right(C.Path, 1) <> "\" Then 'Add trailing backslash
CompletePath = C.Path & "\"
Else'Trailing backslash already present
CompletePath = C.Path
End If
Exit Function
CPErr:
MsgBox Err.Description & " in Function CompletePath()", , App.Title
CompletePath = ""
End Function

Public Function CompletePathString(PathString As String) As String
On Error Goto CPErr
If Right(PathString, 1) <> "\" Then 'Add trailing backslash
CompletePathString = Trim(PathString) & "\"
Else'Trailing backslash already present
CompletePathString = Trim(PathString)
End If
Exit Function
CPErr:
MsgBox Err.Description & "Function CompletePathString()", , App.Title
CompletePathString = ""
End Function

Sub DirKeyPress(DirListBox As Control, KeyAscii As Integer)
Dim P% ' Stores the current ListIndex of the DirListBox control
On Error Resume Next
Static OP% 'Stores old path index. Used when this Sub is called again.
If KeyAscii = vbKeyEnterKey Then
P% = DirListBox.ListIndex
If P% <= -1 Then 'New path is parent of previous one
DirListBox.Path = DirListBox.List(P%)
OP% = DirListBox.ListIndex
Else'New path is one directory deeper than previous one
DirListBox.Path = DirListBox.List(P%)
End If
End If
DirListBox.Refresh
OP% = DirListBox.ListIndex
End Sub

(dirlistnav.html)- by Paolo Puglisi - Modifica del 25/3/2019