ultimate varible

jnash

Well-known member
Joined
Oct 20, 2006
Messages
111
Programming Experience
Beginner
i need a variable where that when the application isnt running its still in there somewhere, i thought smack it in the database but it seems to much coding for a single integer varible.

i was thinking also to put it into a file but i think that is also alot of prigramming for just a single varible, any ideas?
 
Go to your project properties under Settings and create your variable. Then, when you want to get or set it in your code, just do this (for the example, the variable is called "myvar"):

VB.NET:
My.Settings.myvar = 2

This variable will retains its value after you close it and restart the application.

properties.jpg
 
thatas brilliant however it doesnt save what settings should
in my code when i add a user
in the settings part i set the value as 1000

in my code i did

My.Settings.mCode = My.Settings.mCode + 1

it adds the user with 1001

but when closed and started again the varible when adding another user is 1001 again !
 
Under the Application tab of the property pages (shown in the screen shot above) there is a checkbox called 'Save My.Settings on Shutdown'. Make sure that is checked. It should be checked by default.
Also note the shorthand for adding 1 to a variable:
VB.NET:
My.Settings.mCode += 1
 
Back
Top