Is it possible to add to My.Settings at runtime?
-
I wish to persist some user settings such as a list of filenames and thought My.Settings would be the best way to go. However, the number of filenames in the list is unknown. For example... Setting... Name Type Scope Value File1 String User "filename_1" File2 String User "filename_2" File3 String User "filename_3" . . . . . . . . . . . . Filei String User "filename_i" Where 'i' is unknown at design time. Each time the app is run 'i' may get bigger or smaller. Is it possible to add and delete user scope settings in My.Settings at runtime? If not is there a better alternative? Cheers Tim
-
I wish to persist some user settings such as a list of filenames and thought My.Settings would be the best way to go. However, the number of filenames in the list is unknown. For example... Setting... Name Type Scope Value File1 String User "filename_1" File2 String User "filename_2" File3 String User "filename_3" . . . . . . . . . . . . Filei String User "filename_i" Where 'i' is unknown at design time. Each time the app is run 'i' may get bigger or smaller. Is it possible to add and delete user scope settings in My.Settings at runtime? If not is there a better alternative? Cheers Tim
You are probably looking for the definition of an array! simply have:
Dim Files() as String, NumberOfUsers as Long Dim i as long 'Here write the code to get the number of users Redim Files(NumberOfUsers) For i=0 to NumberOfUsers Files(i) = "filename_" & i Next
-
You are probably looking for the definition of an array! simply have:
Dim Files() as String, NumberOfUsers as Long Dim i as long 'Here write the code to get the number of users Redim Files(NumberOfUsers) For i=0 to NumberOfUsers Files(i) = "filename_" & i Next
Thank you for your response. Unfortunately you misunderstood my question. Your response, however, did get me thinking what are the available data types in My.Settings and I found that there is a StringCollection type and this is exactly what I am after:-D. Thanks for the push in the right direction. Cheers Tim