 |
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Plz help
I have tried to change the script a bit, but it just moves items from one listbox to another, but I wanted to move files, which listbox is showing.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
i = ListBox2.SelectedItems.Count - 1
Do While i >= 0
ListBox1.Items.Add(ListBox2.SelectedItems.Item(i))
ListBox2.Items.Remove(ListBox2.SelectedItems.Item(i))
i = i - 1
Loop
|
|
13-08-2011 at 05:10 PM |
|
|
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Re: Plz help
First of all Thanks for the reply. I could not get any help while I was writing the code, but later I tried this, which is working pretty well.
Try
' identify items that have been selected in the listbox
'and moves them from one folder to another
Dim intCount As Integer 'count number of items in the listbox
Dim FileToMove As String
For intCount = 0 To Me.ListBox1.SelectedItems.Count.ToString() - 1
If Not Me.ListBox1.SelectedItems(intCount) Is Nothing Then
FileToMove = Me.ListBox1.SelectedItems(intCount).ToString()
'Move files one by one from source folder to destination folder
Dim fso
Dim file As String, sfol As String, dfol As String
file = FileToMove
sfol = "c:\" & Format(DateTimePicker1.Value, ("MM-dd-yyyy")) & "\" 'source folder path (left side)
dfol = "c:\" & Format(ComboBox1.Text) & "\" 'source folder path (right side)
fso = CreateObject("Scripting.FileSystemObject")
'Check if file exists
If Not fso.FileExists(sfol & file) And Not fso.FileExists(dfol & file) Then
MsgBox(file & " does not exist in the source directory!", vbExclamation, "File Missing in source file")
'If exist replace
ElseIf fso.FileExists(sfol & file) And fso.FileExists(dfol & file) Then
MsgBox(file & " already exists in the destination folder", vbExclamation, "File Duplication")
ElseIf Not fso.FileExists(dfol & file) Then
fso.MoveFile((sfol & file), dfol)
MsgBox(file & " has now been moved!", vbExclamation, "Requested action complete")
Else
MsgBox(file & " has already been moved!", vbExclamation, "File Exists in destination folder")
End If
If Err.Number = 53 Then MsgBox("File not found")
End If
Next
'update listboxes
Dim i, f As Integer
i = ListBox1.SelectedItems.Count - 1
Do While i >= 0
ListBox2.Items.Add(ListBox1.SelectedItems.Item(i))
ListBox1.Items.Remove(ListBox1.SelectedItems.Item(i))
i = i - 1
Loop
f = ListBox2.SelectedItems.Count - 1
Do While f >= 0
ListBox1.Items.Add(ListBox2.SelectedItems.Item(i))
ListBox2.Items.Remove(ListBox2.SelectedItems.Item(i))
f = f - 1
Loop
Catch ex As Exception
WriteLog("Error :" & Date.Now.ToString & " " & ex.Message)
MsgBox("Nothing to Add! Please click 'Remove' Button")
End Try
|
|
29-08-2011 at 02:54 PM |
|
|
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Re: Plz help
Hi GeoffS, Now I have problem with another code. I want to get the play time of media files selected in the listbox. Is it possible to get total play time without opening the media file.
Waiting for reply anxiously. I greatly appreciate any help.
|
|
|
29-08-2011 at 02:58 PM |
|
|
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Re: Plz help
Thanks a ton.
One more confusion. first see the code
Dim selfile As String
For Me.intCount = 0 To Me.ListBox1.SelectedItems.Count.ToString() - 1
If Not Me.ListBox1.SelectedItems(intCount) Is Nothing Then
selfile = Me.ListBox1.SelectedItems(intCount).ToString()
Dim filesize As Long = selfile.Length
TextBox2.Text = filesize
End If
Next
Now it gives me the last selected file's length, which is understood. I want to see all selected files length. Appreciate your help GeoffS.
|
|
30-08-2011 at 03:59 PM |
|
|
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Re: Plz help
Thanks a ton.
|
|
01-09-2011 at 02:58 PM |
|
|
lonelyluminary Level: Protégé
 Registered: 07-08-2011 Posts: 8
|
Re: Plz help
Thanks
|
|
05-09-2011 at 03:17 AM |
|
|
|
|
 |
 |