stringvb6predefined-variables

Is there any way to predefine a string in vb6?


I was trying someting like:

Dim experiment As String = "Predefined experiment string.."

but sadly its not working so is there any way to predefine a string with a similar way in vb6?


Solution

  • For a constant string:

    const experiment As String = "Predefined experiment string.."
    

    At the top of a module/class/form with an access modifier for the corresponding scope, or in a routine as a local.

    For strings with variable content you cannot declare and assign on the same line, you can however:

    Dim experiment As String: experiment = "Predefined experiment string.."