Moving Through The Files In A File List Box...
Hey everyone,
As the title states I am trying to move through files in a file list box. For example...if the file list box contains 3 files and the user selects all 3 and clicks on a delete button, a loop will be activated like below that will update the selected index and call the delete confirmation each time. The problem is I don't know how to get the selected index to change. I have tried filelistbox1.selectedindex.equals(count) but the selected index never changes from 0. If this isn't clear post back and I'll try to explain it better...any help would be greatly appreciated. Thanks in advance
Code:Dim count As Integer = 0
Do Until count = FileListBox1.SelectedItems.Count 'update selected index so when frmdelete is called it uses the right filename
frmdelete.show count = count + 1 Loop
Edited by - piles on 6/20/2007 8:10:01 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Moving Up && Down In File List Box
heyy guyz..
i was wondering...if i have a file list box with many files in it...how can i cause the cursor or watever to move to the next file down or up, to the beginning, and to the end of the list of files (and if possible cause the cursor to move randomly as well)...
and if it does move...under which event would that be?? example: file1_change??
thanxx in advance
Moving Multiple .DAT Files Into One .DAT File
I need to move all of the .dat files in a directory to one large .dat file. I have been successful in moving one .dat file at a time, but not the entire directory. Below is the current code that I have. What do I need to change so that all of the files will be read and moved at once?
Here is the code.
VB:
Option Explicit
Private Sub Form_Load()
On Error GoTo Err_Form_Load
'Open Dialog box to select multiple files
With CommonDialog1
.DialogTitle = "Woohoo"
.InitDir = App.Path
.Flags = &H200& + &H4&
.Filter = "Data files (*.dat)|*.dat"
.Action = 1
End With
'Input #1
Open CommonDialog1.FileName For Input As #1
Err_Form_Load:
End Sub
Private Sub cmdRun_Click()
Dim sTemp As String
'Open file to be written to
Open "s: est_fold est2.dat" For Append As #2
Do Until EOF(1)
Input #1, sTemp
Write #2, sTemp
Loop
Close #1
Close #2
End Sub
How To Get A List Of Files In A Txt File
Try something like:
Code:
Private iFile As Integer
Private Sub Command1_Click()
iFile = FreeFile
Open "C:Log.txt" For Output As iFile
Call LogFiles("*.*", "C:")
Close iFile
Call Shell("notepad.exe C:Log.txt", vbNormalFocus)
End Sub
Private Sub LogFiles(ByVal sFile As String, ByVal sStartDir As String)
Dim sSubDirs() As String
Dim iSubDirs As Integer
Dim sDir As String
If Right$(sStartDir, 1) <> "" Then sStartDir = sStartDir & ""
sDir = Dir(sStartDir & sFile, vbArchive + vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
While Len(sDir)
If Left$(sDir, 1) <> "." Then
If (GetAttr(sStartDir & sDir) And vbDirectory) = vbDirectory Then
ReDim Preserve sSubDirs(iSubDirs)
sSubDirs(iSubDirs) = sDir
iSubDirs = iSubDirs + 1
Else
Print #iFile, sStartDir & sDir
End If
End If
sDir = Dir
Wend
If iSubDirs Then
For iSubDirs = 0 To iSubDirs - 1
Call LogFiles(sFile, sStartDir & sSubDirs(iSubDirs))
Next
End If
End Sub
N.B. If you do the Entire HDD it may take a while.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
File List Or Collection Of Files?
I need to elaborate a big number of text file coming from an instrument.
I used to create a list of the files using DOS command and then open the list and go through the entries one by one.
Now i'm temped to use the common dialog control so that i receive an array of strings (or a collection) and cycle through the elements.
Which way is better in terms of performances and resources? Which one would you use? (optional: Why? )
File List On Win2K = No Files
Try this:
Code:
File1.Pattern = "*.*"
File1.Path = "C:"
File1.Refresh
On a Win2K machine, even when logged in as a user with Admin rights, the File List Box is empty.
Is that strange or what? Any ideas?
A Directory List Of Files To A File
i was wondering if anyone could help me out with one little problem
how can i put a complete list of files from a specified directory using vb?? i want the list to look like this...
file1.zip
file2.zip
file3.zip
file4.zip
file5.zip
file6.zip
etc....
all in one text file
please help me out with this!
Selecting All The Files In A File List Box Via Code...
Just as the title states I am trying to select all the files of a file list box when the user clicks a button. This is the code I developed but it doesn't seem to help.
Code:
Dim count as Integer = 1
Do Until count = FileListBox1.Items.Count
FileListBox1.SelectedItems.Add(count - 1)
count = count + 1
Loop
After the code above is implemented the file list box looks like this...unchanged:
And it should look like this:
Edited by - piles on 6/25/2007 6:23:18 AM
Detecting File Extension To List Files Of Type
My application seeks to identify MS Access database files in a listbox. If a file with the .MDB extension is found, I want to have code behind the scenes which will connect to the database selected and then list all individual Tables within the database in another listbox. Does anybody know how I can do this?
How To Delete Selected Files From Long File List
Hello
i have this small app that search from giving text list for picture files (*.jpg ; *.gif ...)
now i store the files into array, the second operation i need to implant is to look into directory
structure and delete all the files that has the extension *.jpg OR *.gif BUT not the files i have stored there name
in the array , what is the best solution for this?
1.to run every time throw the array to check if the file exist?
2 or there is away to implant somekind of hash table array so i could check if the name of the file im about to delete
is and element of my hash table array? (or something like this...)
thanks
FSO: Delete Dir, Its Files And Subdirs && Write List To Text File
I am using VB6. I have a list of specific files that I need to delete from a Windows file system. I also have a list of directories (whose files and subdirectories can be deleted) that I need to delete.
Even though I know which files and directories I need to delete, I need to be able to show a log of which files were actually deleted.
I am using the FileSystemObject in the Microsoft Runtime Object Library. I know how to use the delete methods of the file and folder objects. I also know how to create a text file in the correct location in the file system.
I need to have a list of all files which have been deleted (with the full path, file name and extension) written to a text file. I am having trouble getting the list written to a text file.
I am listing the folders and files that need to be deleted like this:
folderDelete "c:ApplicationWcBcBarcode"
folderDelete "c:Program FilesWcBcBarcode"
folderDelete "c:PlatformWcBc"
fileDelete "c:ApplicationStartupWcBcBarcode.exe"
fileDelete "c:ApplicationStartupWcBcBarcode.lnk"
fileDelete "c:ApplicationWcBcBarcode.cpy
the sub routines for folderDelete and fileDelete look like this:
Sub fileDelete (fileName)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(fileName) Then objFSO.DeleteFile(fileName)
EndSub
Sub folderDelete (folderName)
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(folderName) Then objFSO.DeleteFolder(folderName)
EndSub
I thought that it would be easy to get the specified "files" into the text file by:
1. declaring a file variable
2. using the CreateTextFile method to specify the name and location for the text file
3. using WriteLine or Write in a manner such as: WriteLine("Deleted: " & fileName)
But I was not able to get it to work.
And, for listing the files in the directories which were deleted, I thought that I should use GetFolder and pass the file names (and full paths) to an array, and then write the array to the text file.
I was not able to get this to work, either.
Can someone please help me to do the following:
1. pass the file names of the files in the directories (and the directory paths themselves) which are being deleted to a list or an array. (shouldn't this happen in the deleteFolder sub routine?)
2. write that list or array to the text file (shouldn't this happen in the deleteFolder sub routine?)
3. write the list of specified files that are being deleted to the text file (shouldn't this happen in the deleteFile sub routine?)
Your help is greatly appreciated.
How Do I Drag Files From A File List Box And Open Them In A Text Box On The Same Form?
Thanks for your help Chris, but here was what I meant to say. sorry! O.k. I am building an HTML editor. O.k on my form I have a Drive List Box, Directory List Box and a File List Box and a Text box. now I know how to make them work, so that I can change the directory, and it will show the folders in the directory list, which shows the files in the File List Box.
But what I wanna do is, i want to be able to drag files from the File List Box and have them open in the Text Box on the same form. I wanna be able to allow the user to drag an HTML file from the File List Box and have it open in the Text Box. Can I do? I sure hope so That's the only thing I can't figure out, is how to drag the file and have it open in the text box. Can any one help me? Thanks for any help you can give me.
Moving Mouse Over The List Box
Hi, I am trying to manually make my own Menu Editor. I don't like how you cannot edit the font and color of the regular menu editor.I got it all working and looking great, but there are 2 small problems that I cannot figure out how to fix.
I want to be able to move the mouse over a list box, and just like a regular menu I want the one that is under the mouse to be highlighted. And as you move the mouse over different selections it will highlight them, without yet clicking on the mouse, anyone know how to do that?
Also, does anyone know how to change the forecolor of a command button? It is possible?
I appreciate any help.
Thanks,
Dan
Moving Items To The End Of The List!
hi!all!
i am looking for a code to move a selected item to the end of the list box!
for example i have a list1 with items
1
2
3
i select the first item ,item 1 and then click the button!
the item should move to the end of the list and the list would look like>
2
3
1
---------------------------
Moving Items Up And Down In A List Box...
Hey guys, I was wondering if anyone can help me on how to move items up and down a list box? Also, if I want to move an item start from the bottom to the top?
Please, help me...
Moving Items Around A List Box
hi !
I have yet another short query here..and would be grateful if anyone could help.
I got a list box with a playlist for a radio show..and to the right of it i have 2 more listboxes..one with duration of track and the other with the point in time at which the track starts in the show.
I have 2 buttons below up and down which when clicked on move the selected item up or down in the playlist accordingly along with the related times.
How do i do this ?
Also how do make sure that there is one item selected at aLL times.
any help would be great !
Harpooon
Moving Lines Within A List Box
hello,
i have a list box and i want to move some lines in it, but here is the catch;
i built the list like this:
i have a 'brake' line and then some other lines starting with " " (4 spaces). it serves me as groups.
what i want to do is move the entire groups up and down.
i keep failing on managing to do this..
it looks something like this:
brake1
line1
line2
line3
brake2
line1
brake3
line1
line2
i have between 2 and 10 brakes and as many lines between them.. (they also have unique names; not 'brake' and 'line').
also,
the up and down buttons are only enabled when i'm on a brake.
they are disabled seperatly when i'm on the first or last brake.
when i click on my up button (for example when i'm on brake3);
it will replace brake2 and look like this:
brake1
line1
line2
line3
brake3
line1
line2
brake2
line1
and so is with the down button (on brake1);
brake3
line1
line2
brake1
line1
line2
line3
brake2
line1
after this, i also want to be able to move the lines up and down, but to disable the buttons when i'm on the first line and the last line.
(i only use 2 buttons; 'CmdUp' and 'CmdDown')
i use this line to tell when it's a line and not a brake;
if left$(list1.listindex,4)=" " then blahblah..
i only managed to get the brake (any) to become the first of the list, and not even go down...
help?
thanks in advance..
Moving All Items From One List Box To Another
I am having problems selecting the first item in the list box. Here is the code that I have written:
Private Sub ZonesAll_Click()
Dim ZoneName As String
Dim ZoneNumber As Integer
Dim n As Integer
Dim i As Integer
n = Me.ZonesNotSelected.ListCount
'I need a line here that will select the top item in the list
For i = 0 To n - 1
Me.ZonesNotSelected.Selected
ZoneName = Me.ZonesNotSelected.Text
ZoneNumber = Me.ZonesNotSelected.ListIndex
Me.ZonesNotSelected.RemoveItem ZoneNumber
Me.ZonesSelected.AddItem ZoneName
Next i
End Sub
Thanks
SLR
Moving List Items Up And Down
This is a bit foolish question bu I forgot how to do it.
I want to move items listed in the list box up or down. How do I do it?
Kinjal
Moving Items Up/Down In List Box W/VB
There is another thread in the javascript section with almost the same title, so what I am wondering is if there is a VB version of it. The thread id is
URL
Any help would be greatly appreciated
Moving List (TreeView VB6)
Hey,
I have a list, and I was wondering if there was a way to move an item e.g. from 3 > 4 or 4 < 3 by clicking on a command button? Also if you can drag and drop them to the position that you want them to be in?
Thank You
Moving A Item In A List Box Up Or Down
I have two buttons on a form and I want the be able to click the up button then move the selected item up or click the down button and have the item go down.
Any Ideas?
Moving Item Between List Boxes
I have a command button with the Caption ">". When clicked I want the selection the user has made in ListBox1 to be moved to ListBox2.
Anyone ever do something like this before?
thx..
Moving Data Between List Boxes
Hi,
I need a little help if anyone has a moment. I have 2 list boxes one called lstSource and the other is lstDestination. I have it set up and working so that I can multi select rows in my source and move them into my value list in my destination list box. I call the function in the click even of a right arrow button. This works great.
Now I want the user to be able to remove fields from the lstDestination in case they make a mistake or change their mind. I want to do this using a left arrow button but I can't quite get the code working properly. I have gotten it to do everything butx but....however, I can't get it to just delete the selected row(s). Here is my code that is working to move my rows from my lstSource to my lstDestination. I assume it must be some variation of this....
<vb code>
Private Sub cmdCopyItem_Click()
CopySelected Me
End Sub
Function CopySelected(frm As Form) As Integer
Dim ctlSource As Control
Dim ctlDest As Control
Dim strItems As String
Dim intCurrentRow As Integer
Set ctlSource = frm!lstSource
Set ctlDest = frm!lstDestination
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
strItems = strItems & ctlSource.Column(0, _
intCurrentRow) & ";"
End If
Next intCurrentRow
' Reset destination control's RowSource property.
ctlDest.RowSource = ""
ctlDest.RowSource = strItems
End Function
</vb code>
Searching For And Moving E-mails In An Outlook PST From A List In Excel Using VBA
Hi there,
I was hoping someone might be able to give me some guidance - I have the task of sorting various e-mails in a master PST, into seperate folders based on a list of e-mail addresses which have been extracted from the PST, and are stored as a simple Excel workbook.
the current list of addresses reaches around 5000 items, and so doing this manually would be a extremely burdensom task - I was hoping that this would made fairly simple by the use of a VBA marco, and it could be easily recorded however Outlook does not allow the recording of macros. I've also been reviewing various samples, but cannot make head nor tail of what needs to be done, and my experience with VBA is fairly limited.
Basically what needs to happen is:
- vba selects the e-mail address from a cell in Excel, and copies this value
- changes to Outlook, and performs a search on the Inbox for the copied value (e-mail adress) as the sender, and then moves any e-mail item found with this value to a seperate folder
- goes back to Excel, and repeats the process to select the next cell's value.
If anyone would be able to help or provide some guidance or sample code, it would be greatly appreciated!
Best regards,
Nick
Create List Of Files From Folder But Allow Double Click On List Item To Run Bat
I am a newbie
But am making some progress
My next plan is to make a simple dialog with a list box and 3 buttons to do the following
List all the batch files in a folder
then allow me to highlight one item in the list so when I click the button it will run that bat file.
Sounds easy enough but I just keep hitting a brick wall and am not making any progress at all.
All help or similar snipits of code that I can re-organise will be greatfully apperciated.
Thanks in advance
Moving Files
VB 6
Need to find away to simply move files(Test.exe) from on location to another.
I have tried FileCopy it act like I have not include the correct libray or component for that function?
Help Quick
Michael Webb
Moving Files
Hello masters! im pretty new in VB6...
my problem is this: I need to write a code wherein the program can do a "cut and paste"
Like this.
I have a file (c:untitled.txt)
in which i want to move (cut) to (d:untitled.txt)
thanks for any input!
Moving Files
Hi, Can somone help please.
I fairly new to VB so I'm sorry if this seams easy but I'm stuck. I'm writing a program that searches a folder picks out certain file names from the search criteria and stores them in a variable.
The above I've done fine but.....
I now need to move all the files of which the names are stored in the variable to a new folder. I've set the form up so users can select the folders they wish to search, and the folders they wish to move files to.
Any help on this will be very much appreciated
Thanks
Rich
Moving Through Files
Didn't know how to title this one. I made an image viewer on one of my forms that has a FileListBox that displays all my image files. I was wondering if it is possible to put next and previous buttons on the form to move forward and backwards through the files?
Moving Files
Hi...How do i change the path of a file?
For example if i know the file is C:Myfilesmysong.mp3
How do i change it to C:mysong.mp3
thanks
Moving Files
Hello,
I'm working on a picture converter for a game and was wondering if there was anyway to move files (not copy, but cut them to the new location). I prefer no APIs, but if that is what it takes, I'll use them. Thanks.
Moving Files?
How would you move a file from one dir to another? Eg:
I want to move "C:Happy.txt" to "C:Program FilesHappy.txt"
How would i do that?
Moving Files
How would I go about moving files to different locations? (eg. as in a text file to a desktop folder) All suggestions would be appreciated.
Moving Files
I have been having problems with a peice of sofware I'm developing.
The software allows the user to select a folder, choose from a search criteria, search the files, and then move the selected files to a folder of their choice. I'm using MoveFileEx and I know it's close to working but it's just not right.
I've attached the program and some relevant files to search. If anyone could have a look and give me a few pointers to where I'm going wrong, it would be much appreciated.
Moving Files...
I need to move a text file into one of three directories depending on what the user chooses... how do I move files?
Moving Files
I would like to move few files (from c:a*.txt to c:*.txt). I use the
following script but it doesn't work:
FileStr = Dir("c:a*.txt")
Do Until FileStr = ""
Name FileStr As "c:*.txt"
FileStr = Dir
Loop
How to correct this??
Thanks!
Moving Files
i want to move different file types to different folders with one command, i have tried this
Code:
Private Sub Command2_Click()
Dim fileop As SHFILEOPSTRUCT
Dim aFileOp() As Byte, nLenStruct&
fileop.hWnd = Me.hWnd
fileop.wFunc = FO_MOVE
fileop.pFrom = "C:WINDOWSTemp*.zip" & vbNullChar & vbNullChar
fileop.pTo = "C:WINDOWSTempIPS" & vbNullChar & vbNullChar
fileop.fFlags = FOF_ALLOWUNDO
fileop.hWnd = Me.hWnd
fileop.wFunc = FO_MOVE
fileop.pFrom = "C:WINDOWSTemp*.mp3" & vbNullChar & vbNullChar
fileop.pTo = "C:WINDOWSTempMP3" & vbNullChar & vbNullChar
fileop.fFlags = FOF_ALLOWUNDO
nLenStruct = LenB(fileop)
ReDim aFileOp(1 To nLenStruct)
Call CopyMemory(aFileOp(1), fileop, nLenStruct)
Call CopyMemory(aFileOp(19), aFileOp(21), 12)
If SHFileOperation(aFileOp(1)) Then
MsgBox "No other files to move", vbOKOnly, "error"
Else
If fileop.fAnyOperationsAborted <> 0 Then
End If
End If
End Sub
but it only moves the .mp3, it completely ignores the first part of the code.
how do you get round this
thanks
thingimijig.
Moving Files
hello, i have a problem that when i 'm doing my homework with visual basic at home, i save my work into my hard drive, and then i copy the whole folder to my diskette and bring it to school, ican't open the project. it will come out with "Path not found in ......."
but i already move the whole folder. how to avoid this happen?
another problem is i'm doing my ADO , once i have to connect to my database in microsoft access, i have to specified the path like
C:my documentdatabasedb1.mbf. when i use another PC, it will lost the connection to the database. my friend said that they can connect without the location of drive which mean that they can just only type in databasedb1.mbf. then they can connect, when move to another PC still will work.but my is difference, it will come out with the message"connection failed", how to make the database available to every PC?
Help With Moving Files
This may be a silly question and it may not be possible but I think i remember seeing something that would work. I am trying to create a program that sorts files on one of the computers at work. I Work at a callcenter and we record the calls onto one main computer. The main computer puts them all into one folder. All I have so far is a program set up on a timer that Creates a folder of todays date if it doesnt exist. Now what I need to do next may be the impossible part. I need to move the files into folders per agent. The files look like this (example):
DerrickR-1278162818_2008-7-16.ccr
DerrickR-1278162420_2008-7-16.ccr
SherryK-1278162637_2008-7-16.ccr
MikeW-1278362420_2008-7-16.ccr
MagnumG-74892017281_2008-7-16.ccr
Is there a way to only use the characters up untill the first hyphen to create a folder for the agent by those characters say "DerrickR" and move the files into it?
Moving Files
I'm trying to move files one at a time. The way I have it set up right now, all the files are being grabbed from the "Input" directory and being sent to the "Output" directory in one shot. I don't want this, I want to be able to sent one file, then grab another, send it and so on. How can I accomplish this?
Thank You,
Chris Koniecny
Fso And Moving Files
i am moving files from one folder to another but i dont want all the files moving, just a certain amount which add upto a desired size.
how would you go about doing something like that.
any ideas !
thanks
thingimijig.
Moving Files Around
OK i have made a Program that Scans my Harddrive for .Vbp files..... once the scan is Finished it then Lists the .Vbp files found in a Listbox (List1). What i want to do is Be able to Move Items from list 1 to 2(ive done that Fine, Now i want ot be able to say, Ok now Move every .vbp in list2 to "C:Vb Projects"(Permenetly, so Next time i run the scan, all the .vbp's are now in "C:Vb Projects" and nowhere else on the comp)) how would i go about doing this??
This is my code so far
[highlight=VB]
dim Oldpath, newpath As String
Oldpath = "C:Program FilesMicrosoft Visual StudioVB98"
newpath = "C:Vb Projects"
FSys.MoveFile Oldpath,newpath
sub end
[vbcode]
Ok this isnt working... its saying it need an array (newpath does)
Plz help ASAP
Moving Files
OK i have made a Program that Scans my Harddrive for .Vbp files..... once the scan is Finished it then Lists the .Vbp files found in a Listbox (List1). What i want to do is Be able to Move Items from list 1 to 2(ive done that Fine, Now i want ot be able to say, Ok now Move every .vbp in list2 to "C:Vb Projects"(Permenetly, so Next time i run the scan, all the .vbp's are now in "C:Vb Projects" and nowhere else on the comp)) how would i go about doing this??
|