Results 1 to 6 of 6

Thread: if pic isnt found. . .

  1. #1

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Unhappy

    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???

  2. #2
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  3. #3

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Angry IT DIDNT WORK!!!

    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?

  4. #4
    Member
    Join Date
    Nov 2000
    Location
    Palma de Mallorca, Spain
    Posts
    39

    Cool That's easy

    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
    Code:
    On Error goto Hell

  5. #5
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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.
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  6. #6

    Thread Starter
    Banned
    Join Date
    Dec 2000
    Location
    USA, NJ
    Posts
    72

    Question !?!?!?!?!?!?

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width