Private Sub Form_Load()
If Me.csvUpload Then
File1.Pattern = "*.csv"
Me.Caption = "CSV File Upload"
Else
File1.Pattern = "*.tcl;*.htm;*.html;*.jpeg;*.gif;*.swf;*.txt;*.pdf;*.css;*.xml;*.png;*.tar;*.tgz"
End If
End Sub
In this code, it takes only those files as above.
If file name is like "copy file1 a.html", I do not want to see this file when I do upload files.
How can I do that??
I'm not 100% sure I understand what you are doing but you could possibly use InStr() to see if the file name has a " " in it and if so skip the file in the upload????
Dim objFSO As New FileSystemObject
Dim objFile As File
For Each objFile In objFSO.GetFolder(App.Path & "\").Files
If InStr(1, objFile.Name, " ", vbBinaryCompare) = 0 Then
Combo1.AddItem objFile.Name
End If
Next objFile
I suspect you are using the FileListBox control. There aren't any methods that I am aware of to remove files with spaces in their name from being listed.
Of course, there are smarted guys than me in here. Maybe they have a better idea.
The only way around this problem that I can think of would be to use a *regular* list box and fill the list box manually, using the method that vladk suggests.
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
Total agreement, I have been looking at it along the same lines. You may have to use an OR statement or something along those lines to only include files with the extention you are after.
If InStr(1, "*.html", " ", vbBinaryCompare) = 0 Then
File1.Pattern = "*.tcl;*.htm;*.html;*.jpeg;*.gif;*.swf;*.txt;*.pdf;*.css;*.xml;*.png;*.tar;*.tgz"
End If
So.. don't use that file list box. Use regular one and manage it via code. Look at my example. Set reference to Microsoft Scripting Runtime first and you will gain almost unlimited control over your files and directories.
Although it prevents from highlighting, it also prevents from using arrow up/down - the navigating inside File1: the scrolling chocks on the unwanted files.
Yes...I did not want to see the files with spaces..
So...I think vladk's idea was good...
But it was difficult to change my current code using your idea...
So, Instead of not showing the files with spaces, I use that way..
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.