Click to See Complete Forum and Search --> : if pic isnt found. . .
nukem996
Dec 29th, 2000, 10:21 PM
in my program i use an ini and you can set a pic as the backround. but what if the user moves the pic to somewhere else on thier computer? the program crashs. how would i make an err msg come up and make it not load the pic???
YoungBuck
Dec 29th, 2000, 10:32 PM
Use the Dir function to check and see if the path exists..
If Dir("C:\MyPic.bmp") <> "" Then
LoadBackGround
Else
MsgBox "Your Background Image Was Not Found!", vbOkOnly or vbcritical, "Error!"
End If
nukem996
Dec 29th, 2000, 11:33 PM
i put the code in and the same thing happend. and whats w/ the C:\MyPic.bmp? The user selected the pic and it could be any where w/ any name. the file location is in the ini. is the "LoadBackGround" where i put the code, cause i did. and when i had it in it didnt work!!!
so whats up with this?
M@rk
Dec 30th, 2000, 07:13 AM
Why don't you just put somewhere in your program a picturebox with the image you want to load from the ini and set it's visible property to false, then you can load the picture just with
Picture1.picture = Picture2.picture
YoungBuck
Dec 30th, 2000, 07:56 AM
nukem996,
"C:\MyPic.bmp" is for example purposes only, replace it with the variable that holds the path you received from the INI file and try it again. I am sure that if you tried the code with "C:\MyPic.bmp" then it didn't work.
nukem996
Dec 30th, 2000, 11:37 AM
i put this code in the way you told me to and in my program it defines pic and loadpicture(pic), but it still dosent work!!! gives me this error, "Bad file name or number," on this line of code "if dir(pic) <> "" Then."
pic = E:\pic\stairs.gif
so what the problem?
code:
If Dir(pic) <> "" Then
'LoadBackGround
frmmedia.Picture = LoadPicture(pic)
Else
MsgBox "Your Background Image Was Not Found!", vbOKOnly Or vbCritical, "Error!"
End If
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.