Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Is it possible to add to My.Settings at runtime?

Is it possible to add to My.Settings at runtime?

Scheduled Pinned Locked Moved Visual Basic
designtutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TJO1
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • T TJO1

      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

      M Offline
      M Offline
      MohammadAmiry
      wrote on last edited by
      #2

      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
      
      T 1 Reply Last reply
      0
      • M MohammadAmiry

        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
        
        T Offline
        T Offline
        TJO1
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups