Question

I am working on an old VB6 project. There, I have a Const

Private Const INI_PATH = "C:\MyPath\MyINI.INI"

Now the INI_PATH has changed from being always set to "C:\MyPath\MyINI.INI", instead now can either be in another directory or at the original location.

I have a function which can be used to get the INI path now according to some conditions.

Public Function GetINIPath() As String

I was wondering if there is anyway I would be able to do something like

INI_PATH = GetINIPath()

So, everywhere the INI_PATH was being used, now uses the new path based on the function.

I see that there is no #define or similar in VB6. Do I have any other alternative other than changing all instances of INI_PATH into the function GetINIPath()?

Was it helpful?

Solution

As you say, there is no concept of alias or #define in VB6.

But if you don't mind causing a bit of potential confusion for the maintainer, you could do:

Private Function INI_PATH() As String
    INI_PATH = <whatever>
End Function

OTHER TIPS

In VB you do not need parens when calling a function with no arguments, so just create a function called INI_PATH and your code will still work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top