App.Path in module constant
Hi i'm noob to VB. I'm trying to use app.path in a constant in a form like:
Const d_Svt = App.Path
It obviously doesn't work but how can i make that const the apps path?
Any help great thanks
VB Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="1234.exe"
type="win32"
/>
<description>A Description</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Re: App.Path in module constant
i dont get it, the apps path is constant....
Re: App.Path in module constant
I have a constant in a module I want to change from "C:\Program Files\" to app.path. How can I do this?
Thanks
Re: App.Path in module constant
You can't make a constant out of something that is essentially a variable like App.Path since it's value may change with each installation. You can however create a variable, set it equal to App.Path (once) and use it just like you would a constant.
Re: App.Path in module constant
You cannot change a CONSTANT. Once it is defined, it is static. You also cannot set the app.path to a constant. You must use a string.
This is what I use to let my program know where the app.path is:
VB Code:
Public Function GetAppPath() As String
Dim strPath As String
strPath = App.Path
If Right$(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
GetAppPath = strPath
End Function
I call it once and then refer to the global string.
Re: App.Path in module constant
You can simplify that
VB Code:
Public Function GetAppPath() As String
If Right$(App.Path, 1) <> "\" Then
GetAppPath = App.Path & "\"
Else
GetAppPath = App.Path
End If
End Function