Global Variable of All Forms

retkehing

Well-known member
Joined
Feb 5, 2006
Messages
153
Programming Experience
Beginner
I want to create the form that allows the user to key in the DataSource of the connection string because the DataSource can be different from one device to another device. After the user keys in the DataSource, i want to pass this DataSource string to all other forms where the database connection is required.

May i know how to make this string can be used globally but not locally? I am thinking of using database and i don't think is a good way because it uses up the resource and users are not interested in this information.
 
Last edited:
Sorry, i am beginner, can you show me a sample code on module about how to pass the string, and how to retrieve it in the form. Thank you.
 
I see you have set: Primary Platform: .NET 2.0

So here how you can use My.Settings object.

- Double click My Project in your Solution Explorer
- Go to Settings section
- Insert new setting (global variable), set name, type (String), scope (user if you want to be able to change it runtime) and value
- In code get value like:

VB.NET:
Me.MyTextBox.Text = My.Settings.NameOfYourSetting
- If you want to change value in settings:

VB.NET:
My.Settings.NameOfYourSetting = Me.MyTextBox.Text
 
Back
Top