Private Sub CommandButton1_Click()
Dim i As Integer, resim, cevap As String
If ListBox1.ListIndex = -1 Then
MsgBox "The listbox item isn't selected to delete !", vbCritical, ""
Exit Sub
End If
resim = ThisWorkbook.Path & "\"
If ListBox1.ListIndex >= 0 Then
cevap = MsgBox("Entry will be deleted. ... Are you sure ?", vbYesNo)
If cevap = vbYes Then
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Kill ThisWorkbook.Path & "\" & ListBox1.Value
ListBox1.RemoveItem (i)
If ListBox1.ListCount = 0 Then
Image1.Picture = LoadPicture("")
End If
End If
Next i
End If
End If
End Sub
Private Sub CommandButton2_Click()
Dim dosya, cevap, resim As String
ChDir "C:\"
dosya = Application.GetOpenFilename(FileFilter:="," & "*.jpg", _
Title:="Lütfen resim seçimi yapýnýz")
resim = ThisWorkbook.Path & "\"
If dosya = False Then
Exit Sub
Else
Image3.Picture = LoadPicture(dosya)
cevap = MsgBox("The selected picture will be added to the folder... Are you sure ?", vbYesNo)
If cevap = vbYes Then
SavePicture Image3.Picture, resim & GetFileName(CStr(dosya))
Else
Image3.Picture = LoadPicture("")
Exit Sub
End If
End If
ListBox1.Clear
UserForm_Initialize
Image3.Picture = LoadPicture("")
End Sub
Private Sub Image1_Click()
Unload Me
UserForm1.Show
End Sub
Function GetFileName(dosya As String)
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
GetFileName = fso.GetFileName(dosya)
End Function
Private Sub Image3_Click()
Unload Me
UserForm1.Show
End Sub
Private Sub ListBox1_Click()
Image1.Picture = LoadPicture(ThisWorkbook.Path & "\" & ListBox1.Value)
End Sub
Private Sub SpinButton1_SpinDown()
On Error Resume Next
If ListBox1.ListIndex = ListBox1.ListCount - 1 Then Exit Sub
With Me.ListBox1
.ListIndex = .ListIndex + 1
End With
End Sub
Private Sub SpinButton1_SpinUp()
On Error Resume Next
If ListBox1.ListIndex = 0 Then Exit Sub
With Me.ListBox1
.ListIndex = .ListIndex - 1
End With
End Sub
Private Sub UserForm_Initialize()
Dim fso As Object, dosyam As Variant
Set fso = CreateObject("Scripting.FileSystemObject")
For Each dosyam In fso.GetFolder(ThisWorkbook.Path).Files
evn = fso.GetExtensionName(ThisWorkbook.Path & "/" & dosyam.Name)
If evn = "jpg" Then ListBox1.AddItem dosyam.Name
If ListBox1.ListCount > 0 Then
ListBox1.Value = ListBox1.List(0)
End If
Next
Set fso = Nothing
End Sub