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???
Printable View
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???
Use the Dir function to check and see if the path exists..
Code:
If Dir("C:\MyPic.bmp") <> "" Then
LoadBackGround
Else
MsgBox "Your Background Image Was Not Found!", vbOkOnly or vbcritical, "Error!"
End If
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?
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
Code:Picture1.picture = Picture2.picture
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.
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