Hi, I have a DirListBox (the yellow folder thing on your tool box) and a textbox
so how do I copy line for line from the dirlistbox to the text box?
hope that was clear
Visual Programmer
Printable View
Hi, I have a DirListBox (the yellow folder thing on your tool box) and a textbox
so how do I copy line for line from the dirlistbox to the text box?
hope that was clear
Visual Programmer
Code:Private Sub Command1_Click()
Dim iDir As Integer
For iDir = 0 To Dir1.ListCount - 1
Text1.Text = Text1.Text & Dir1.List(iDir) & vbCrLf
Next iDir
End Sub
thanks matthew, now how would I go about doing the same thing but for a file list, instead of the dir list
Visual Programmer
Same exact thing, just change Dir1 to File1 and iDir to iFile if you want.
Code:Private Sub Command1_Click()
Dim iFile As Integer
For iFile = 0 To File1.ListCount - 1
Text1.Text = Text1.Text & File1.List(iFile) & vbCrLf
Next iFile
End Sub
Thanks once again.....
and 1 final question.....
is it possible to get rid of the extension?
To remove the file extension:
Code:Private Sub Command1_Click()
Dim iFile As Integer
For iFile = 0 To File1.ListCount - 1
Text1.Text = Text1.Text & Left(File1.List(iFile), Len(File1.List(iFile)) - 4) & vbCrLf
Next iFile
End Sub
Matthew, not all extensions are 4 characters long (3 + . = 4 ;))
So use this API function to get rid of the extension:
cool huh? : )Code:Declare Sub PathRemoveExtension Lib "shlwapi.dll" Alias "PathRemoveExtensionA" (ByVal pszPath As String)
Private Sub GetRidOfExt_Click()
Dim Path$
Path = "c:\file.ext" 'fill the path into a string
PathRemoveExtension Path 'get the path without the ext.
MsgBox Path 'show the new path without ext.
End Sub
wheter your extension is .mp3 or .pl, it removes it :p
Thanks 2 both
Visual Programmer