Untuk menyingkat nama path, kita membutuhkan fungsi API PathCompactPathEx. Berikut code untuk menyingkat nama path :
Option Explicit Private Declare Function PathCompactPathEx Lib "shlwapi.dll" Alias "PathCompactPathExA" ByVal pszOut As String, ByVal pszSrc As String, ByVal cchMax As Long, ByVal dwFlags As Long) As Long 'simpan dalam modul Public Function ShortFilePath(FilePath As String, Optional MaxLen As Long = 40) As String Dim ShortPath As String On Error Resume Next ShortPath = String(255, 0) PathCompactPathEx ShortPath, FilePath, MaxLen, 0 ShortFilePath = ShortPath End FunctionContoh penggunaan prosedur di atas:
Private Sub Form_Load() Text1.Text = ShortFilePath("F:\Project\Outlook Bar control + Photoshop Color Picker v1.3.2\3. Samples\Images") 'akan menghasilkan "F:\Project\Outlook Bar con...\Images" End Sub
Semoga Bermanfaat ..
No comments:
Post a Comment