Hello,
I have a function that checks to see if an image file exists on the harddrive:
VB Code:
Private Function DoesExist(ByVal strName As String) As Boolean On Error GoTo Errorhandler ' goto error handler if file doesn't exist Dim sFile As Long sFile = FreeFile() 'get a free file # Open strName For Input As sFile Close sFile DoesExist = True 'return if file was opened Exit Function Errorhandler: DoesExist = False 'return false if error occured - meaning file was NOT found End Function
Here is the function I'm trying to write so that if the file does exist, then create the same one but add (1), (2), etc. to the end of the file right before the .bmp extension.
The label boxes (which is already populated) is used in naming this image file.
VB Code:
Private Function SaveSixPack2() If DoesExist("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & ".bmp") = False Then SavePicture Picture13.Picture, ("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & ".bmp") End If If DoesExist("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & ".bmp") = False Then Exit Function Else SavePicture Picture13.Picture, ("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & "(" & "1" & ")" & ".bmp") End If If DoesExist("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & "(" & "1" & ")" & ".bmp" & "C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & ".bmp") = False Then Exit Function Else SavePicture Picture13.Picture, ("C:\SixPackImages\" & Generator.lblSixCR.Caption & "-" & "SixPack" & "(" & "2" & ")" & ".bmp") End If End Function
So my problem is: the first two "If DoesExists" work but the last one doesn't for some reason..... any suggestions?
Thanks!'
Chris


Reply With Quote