Hi All

Does Anyone know how to make a variable public to all forms within the application.

Eg Public MyPath = "C:\" can do for one form but not all

Recommended Answers

All 3 Replies

If your Public declaration is on Form1, then call it like: [B]Form1.MyPath[/B] from any other Form.

Also, always set a Declaration Type when declaring something. In this case, "String" = Type.

Public MyPath As String = "C:\"
Member Avatar for Unhnd_Exception

Another thing you could do is add a module to the project.

Module FilePathData
    Public MyPath as String = "C:\"
    'Some other stuff
End Module

Thanks to you both for the ideas.

I will take them onboard and use them.

codeorder - thank you once aagin for the help, the advice you give is always simple and to the point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.