TJ2002
asked on
Deleting a file using if Keycode... HLP PLS
Hello,
Im want to del a file using the DEL key.
this is the code that won't work
Private Sub File1_Click()
SelectedFile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)
If KeyCode = vbKeyDelete Then GoTo Kill
Exit Sub
Kill:
MsgBox "Are you sure?"
Kill File1.Path & "\" & File1.FileName
File1.Refresh
End Sub
What is wrong ?!?
ThnX, TJ2002
Im want to del a file using the DEL key.
this is the code that won't work
Private Sub File1_Click()
SelectedFile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)
If KeyCode = vbKeyDelete Then GoTo Kill
Exit Sub
Kill:
MsgBox "Are you sure?"
Kill File1.Path & "\" & File1.FileName
File1.Refresh
End Sub
What is wrong ?!?
ThnX, TJ2002
ASKER
thnx,
but the loadPicture wont work any more....
is it also posible to use it whit multi files??
TJ
but the loadPicture wont work any more....
is it also posible to use it whit multi files??
TJ
I had some extra code in there from pasting:
Integer, X As Single, Y As Single)
(I'm sure you got rid of that)
is the file a valid picture file you're selecting from the File1 list?
for multiple files selected you will have to loop through each selected item and kill them.
Integer, X As Single, Y As Single)
(I'm sure you got rid of that)
is the file a valid picture file you're selecting from the File1 list?
for multiple files selected you will have to loop through each selected item and kill them.
ASKER
Yep.. i removed the Integer, X As Singl....
im sure that the image is valid... it works whit te 'OLD' code...
PS; the code is for a FileListBox!!, i for got to say that;p
TJ2002
im sure that the image is valid... it works whit te 'OLD' code...
PS; the code is for a FileListBox!!, i for got to say that;p
TJ2002
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
THANX....
It's working..
GreetZ
TJ2002
It's working..
GreetZ
TJ2002
this should delete all selected
Private Sub File1_Click()
Dim SelectedFile As String
SelectedFile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)
End Sub
Private Sub File1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then GoTo Kill
Exit Sub
Kill:
Dim i As Integer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) = True Then
Kill File1.Path & "\" & File1.List(i)
End If
Next i
File1.Refresh
End Sub
Private Sub File1_Click()
Dim SelectedFile As String
SelectedFile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)
End Sub
Private Sub File1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then GoTo Kill
Exit Sub
Kill:
Dim i As Integer
For i = 0 To File1.ListCount - 1
If File1.Selected(i) = True Then
Kill File1.Path & "\" & File1.List(i)
End If
Next i
File1.Refresh
End Sub
yw, thx for the points
Private Sub File1_KeyUp(KeyCode As Integer, Shift As Integer)
Integer, X As Single, Y As Single)
SelectedFile = File1.Path & "\" & File1.FileName
Image1.Picture = LoadPicture(SelectedFile)
If KeyCode = vbKeyDelete Then GoTo Kill
Exit Sub
Kill:
MsgBox "Are you sure?"
Kill File1.Path & "\" & File1.FileName
File1.Refresh
End Sub