Results 1 to 11 of 11

Thread: VB6 Question.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    english tyrant's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Colchester
    Posts
    2,112

    Default VB6 Question.

    I may be missing something blindingly obvious but is there a way in VB6 for the program to return the location of the project file i.e. "D:/My stuff/program/Project1.vbp"

    Why do I ask? well I am working on this program at College and at home, and when it loads picture files within the program at home obviously the Drive and folder structure where the files are located are different.
    Say at College it might be
    "N:/Student/Documents/Program/Picture1.jpg"
    But at home..
    "D:/My stuff/Program/Picture1.jpg"
    This means I would have to go through the code and change all the directory locations individually whenever I move the file?

    So obviously if I can get VB to return the location of the project then I can manipulate this to the path of the picture.

    If you have another idea I'd be glad to hear it.

    Thanks

  2. #2
    Eat Meat Whale Meat
    Technical Staff Citizen Moderator Emeritus

    Join Date
    Jun 2006
    Posts
    15,812

    Default Re: VB6 Question.

    If your program is located in "d:\program root", wouldn't all non-full paths use that as the root? So have all your image files in the same folder as your .exe, or store the image files in "d:\program root\images", and have your program refer to "\images\image name.jpg".

  3. #3
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: VB6 Question.

    I no longer have VB6 installed but its either app.path or application.path. So you would do something like:

    Dim GlobalPath as String

    GlobalPath = app.path & "\FolderName\FileName"

  4. #4
    Dewy's Avatar Something Witty
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    4,697

    Default Re: VB6 Question.

    Don't use the full path only part of it, like what pannonian said. GED's way does work but I suggest not using it for efficient code.
    Oh no the picture of my dog disappeared!

  5. #5
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: VB6 Question.

    Quote Originally Posted by Dewy View Post
    Don't use the full path only part of it, like what pannonian said. GED's way does work but I suggest not using it for efficient code.
    Using Panns way does not always give you the correct result, which is why app.path was created in the first place. Just off the top of my head I can remember having issues with virtual paths, or even on mapped drives. Using app.path gives you the Fully Qualified File Name, which is similar to Fully Qualified Domain Name, there can be no ambigous results.

  6. #6
    Dewy's Avatar Something Witty
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    4,697

    Default Re: VB6 Question.

    Quote Originally Posted by GrnEyedDvl View Post
    Using Panns way does not always give you the correct result, which is why app.path was created in the first place. Just off the top of my head I can remember having issues with virtual paths, or even on mapped drives. Using app.path gives you the Fully Qualified File Name, which is similar to Fully Qualified Domain Name, there can be no ambigous results.
    Any source (not source code) to back up your claim that app.path was created for? Can you give me examples of panns way not giving the correct result?
    Oh no the picture of my dog disappeared!

  7. #7
    GrnEyedDvl's Avatar Liberalism is a Socially Transmitted Disease
    Artifex Technical Staff

    Join Date
    Jan 2007
    Location
    Denver CO
    Posts
    23,851
    Blog Entries
    10

    Default Re: VB6 Question.

    Quote Originally Posted by Dewy View Post
    Any source (not source code) to back up your claim that app.path was created for?
    If I wanted to dig out 12 year old school books I could. But the common sense answer to this is that obviously at some point somebody NEEDED to know the fully qualified path for an installation, and then allow it to be converted back and forth from string to object.


    Can you give me examples of panns way not giving the correct result?
    Yes. Build an application that runs something from a folder on another machine, and then run it from a second client machine.


    Here is the MSDN official use for app.path. As you can see its just as I have written it.
    http://msdn.microsoft.com/en-us/libr...w2(VS.80).aspx
    Last edited by GrnEyedDvl; December 01, 2010 at 05:10 PM.

  8. #8
    Dewy's Avatar Something Witty
    Join Date
    Jun 2008
    Location
    Australia
    Posts
    4,697

    Default Re: VB6 Question.

    Quote Originally Posted by GrnEyedDvl View Post
    If I wanted to dig out 12 year old school books I could. But the common sense answer to this is that obviously at some point somebody NEEDED to know the fully qualified path for an installation, and then allow it to be converted back and forth from string to object.
    Misinterpreted your post, I thought you mean app.path was created for referencing files such as images not for having the full path of were the program is executed from.


    Quote Originally Posted by GrnEyedDvl View Post
    Yes. Build an application that runs something from a folder on another machine, and then run it from a second client machine.
    I don't use vb6 so it could be different (another reason why visual basic is horrible in my opinion); however I have programmed software in other programming languages that runs something from a folder and it works on all the computers I have tested it on and worked on all the computers it was deployed to.
    Oh no the picture of my dog disappeared!

  9. #9
    english tyrant's Avatar Domesticus
    Join Date
    Dec 2006
    Location
    Colchester
    Posts
    2,112

    Default Re: VB6 Question.

    I just used GED's way and it seemed to work fine. I understand what Pann was saying but if that was the case then it would seem odd as to why app.path exists, no?

    Thanks for your help and speedy replies, it's appreciated.

Posting Permissions

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