Results 1 to 8 of 8

Thread: [Resolved]AHH!!! What's going on here! app.*

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    [Resolved]AHH!!! What's going on here! app.*

    When i have this msgbox come up in VB, it says

    VB Code:
    1. MsgBox "Location: " & App.path & "\" & App.EXEName & ".exe"

    Says: "C:\VB\MyApp\MyProgram.exe"

    When i compile it, it then says "C:\VB\MyApp\\MyProgram.exe"

    But if i put this code in
    VB Code:
    1. MsgBox "Location: " & App.path &  App.EXEName & ".exe"

    VB says "C:\VB\MyAppMyProgram.exe"

    But compiling it says "C:\VB\MyAppMy\Program.exe"


    What's going on here!
    It's taken me ages to figure this out, i'm trying to have a program copy itself to a location on the harddrive (such as programfiles) because it rights to the registery to start it self up with windows, and the control panel needs a location for the program (i have an option in control panel. I can post my entire project here if you want, but i think it will take too long for any of you to go through. So if you can tell me which one of these msgboxes are liars, or another way to fix this problem.

    Thanks!
    Last edited by Slyke; Aug 2nd, 2006 at 04:32 AM.

  2. #2
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: AHH!!! What's going on here! app.*

    MsgBox "Location: " & App.path & "\" & App.EXEName & ".exe"

    works for me ... whats the app's actual folder when compiled ?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: AHH!!! What's going on here! app.*

    VB Code:
    1. MsgBox "Location: " & App.path & "\" & App.EXEName & ".exe"

    In VB:
    Path: C:\Program Files\Microsoft Visual Studio\VB98\Drive Backup\Drive Back Up.exe

    Compiled to an Exe:
    Path: C:\Temp\\DriveBackup.exe

    VB Code:
    1. MsgBox "Location: " & App.path & App.EXEName & ".exe"

    In VB:
    Path: C:\Program Files\Microsoft Visual Studio\VB98\Drive BackupDrive Back Up.exe

    Compiled to an Exe:
    Path: C:\Temp\DriveBackup.exe

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: AHH!!! What's going on here! app.*

    the first one is the right one, make a new exe just with that msgbox and test it. i just tried in c:\temp and made an exe called DriveBackup.exe, ran it from there and it was correct.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: AHH!!! What's going on here! app.*

    VB Code:
    1. Public Function FixPathFile(ByVal Path As String, File As String) As String
    2.     If Right$(Path, 1) <> "\" Then
    3.         FixPathFile = Path & "\" & File
    4.     Else
    5.         FixPathFile = Path & File
    6.     End If
    7. End Function

    VB Code:
    1. MsgBox "Location: " & FixPathFile(App.path, App.EXEName & ".exe")




    Edit
    Btw, root of drives, such as C:\ and D:\, always have the \ character in the end. The only reliable way is to check if the \ character exists in the end of the path string.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: AHH!!! What's going on here! app.*

    Don't worry... It works fine if i leave out the App.EXEName
    I'll just make sure i tell people not to rename it.

    Thanks any ways!

  7. #7
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: [Resolved]AHH!!! What's going on here! app.*

    no prob .. maybe leave it in then use ..

    Dim sApp As String
    sApp = Replace(App.Path & "\" & App.EXEName & ".exe", "\\", "\")
    MsgBox "Location: " & sApp

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    Re: [Resolved]AHH!!! What's going on here! app.*

    Yes, i'm using your code any way from now on, thanks for this!

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