-
September 21st, 2006, 10:06 PM
#1
Error Trap
this is code i am useing in my program to load a picture if for some reason the picture is deleted or moved the program will give a error and close down what i need for this to do is have a error trap where if the picture is deleted or moved it will show another picture in the picture box
Code:
Private Sub Form_Load()
Close
arb = 0
'cd2.Filter = "Image Files (*.*)|*.*"
Filename$ = cd2.Filename
txtpictures.Text = Filename$
Recordlen = Len(person)
Filenum = FreeFile
Open "c:\program files\bondsman\info.dat" For Random As Filenum Len = Recordlen
If carryover > 0 Then Currentrecord = carryover Else Currentrecord = 1
Lastrecord = FileLen("c:\program files\bondsman\info.dat") / Recordlen
If Lastrecord = 0 Then
Lastrecord = 1
End If
ShowCurrentrecord
frmPicture.open.Picture = LoadPicture(txtpictures.Text)
End Sub
thank you for any help you can give
-
September 22nd, 2006, 12:32 AM
#2
Re: Error Trap
I'm not sure what you are doing when you're reading the file, but, here is a standard Error Trap. Sorry if I couldn't test it. It was from memory.
Code:
Option Explicit
Private Sub Form_Load()
On Error GoTo ErrorSub
ShowCurrentrecord
frmPicture.open.Picture = LoadPicture(txtpictures.Text)
Exit Sub ' Exits if NO ERROR
ErrorSub:
frmPicture.open.Picture = "default"
On Error GoTo 0
End Sub
-
September 22nd, 2006, 08:56 AM
#3
Re: Error Trap
Instead of using an error trap for this I think you would be better off checking to see if the file exists before trying to open it. Then, check to see if the backup file exists before you open it. If you can't open either, display a message somewhere that the file was unavailable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|