|
-
Jun 23rd, 2002, 09:51 PM
#1
Thread Starter
Fanatic Member
Directory Listbox Question
This should be an easy one. What I want to do is on the
Dir1 click event I want to create a text file. This I can do. However, want the created file to be named after the folder that was clicked in the Dir1. So Say I click the "ROCK" folder, I want a textfile to be created that is called "Rock.txt". The trouble I'm having is it just creates a folder named "dir1.txt" no matter what folder is clicked. I hope this makes sense. So I guess I don't really want the textfile named: Dir1.name
Is there a way to create a file based on the name of the selected folder in the Directory Listbox? Any help is appreciated.
-
Jun 23rd, 2002, 10:16 PM
#2
Hyperactive Member
The following code will give you the proper filename:
Code:
Private Sub File1_Click()
Dim sFileName As String
sFileName = File1.List(File1.ListIndex)
sFileName = Left(sFileName, InStr(sFileName, ".") - 1) & ".txt"
End Sub
Sometimes what you're looking for is exactly where you left it.
-
Jun 23rd, 2002, 10:23 PM
#3
Thread Starter
Fanatic Member
Maybe I'm wrong but....
What I'm wanting to do is Name the file after the FOLDER that is clicked in the directory listbox, not the name of the file in the filelistbox.
-
Jun 23rd, 2002, 10:27 PM
#4
Hyperactive Member
Sorry, try this:
Code:
Private Sub Dir1_Click()
Dim sDirName As String
sDirName = Dir1.List(Dir1.ListIndex)
sDirName = Right(sDirName, Len(sDirName) - InStrRev(sDirName, "\")) & ".txt"
End Sub
Sometimes what you're looking for is exactly where you left it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|