BENNETT4455
01-20-2008, 07:09 AM
Hi this is my first time here and I am new to VB. I have tryed to construnct a code that finds a .jpg file inside a folder, As the file name changes all the time it is hard to get a lock on. any help appriciated many thanks in advance Bennett
Private Sub Command0_Click()
Dim SEARCHNUMBER As String 'loop string
Dim filename As String 'filename string
'compiling string to renaming and copy
filename = "M:\settings\Desktop\New Folder (3)\" & txtname & ".jpg"
'create loop SEARCHNUMBER = 0
For intNumber = 1578 To 2000
SEARCHNUMBER = SEARCHNUMBER + intNumber
On Error Resume Next
Next intNumber
FileCopy "M:\settings\Desktop\New Folder (3)\" & SEARCHNUMBER & ".jpg", filename
On Error Resume Next
' then delete sorce
Kill "M:\settings\Desktop\New Folder (3)\" & SEARCHNUMBER & ".jpg"
Dim CHKFL As String
' Check if folder exists, first.
If Dir("C:\Dir", vbDirectory) = vbNullString Then
Exit Sub
End If
' Check if file existsCHKFL = Dir$("C:\Dir\File.exe")
If CHKFL = "File.exe" Then
Kill ("C:\Dir\File.exe")
End If
End Sub
Private Sub Command0_Click()
Dim SEARCHNUMBER As String 'loop string
Dim filename As String 'filename string
'compiling string to renaming and copy
filename = "M:\settings\Desktop\New Folder (3)\" & txtname & ".jpg"
'create loop SEARCHNUMBER = 0
For intNumber = 1578 To 2000
SEARCHNUMBER = SEARCHNUMBER + intNumber
On Error Resume Next
Next intNumber
FileCopy "M:\settings\Desktop\New Folder (3)\" & SEARCHNUMBER & ".jpg", filename
On Error Resume Next
' then delete sorce
Kill "M:\settings\Desktop\New Folder (3)\" & SEARCHNUMBER & ".jpg"
Dim CHKFL As String
' Check if folder exists, first.
If Dir("C:\Dir", vbDirectory) = vbNullString Then
Exit Sub
End If
' Check if file existsCHKFL = Dir$("C:\Dir\File.exe")
If CHKFL = "File.exe" Then
Kill ("C:\Dir\File.exe")
End If
End Sub