|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SaveSetting questionI've used the SaveSetting/GetSetting scenario for quite some time - and I know how to do a pretty flat-style Setting - -hoever, I'm having a hard time 'putting my head around' what I need here. Normally, I'd do something like this: SaveSetting App.Title, "Settings", "OptionsTblBrdrWidth", iTableBorderWidth But, here - - I want to save (and get) a specific section ("Table Settings"), then -- under that section, I need to save separate profiles, based on the name of the profile - - Like Basic/Maroon/Blue, whatever, so I'd like to get: Table Settings Basic TableWidth="400" TableBorder="1" SecondProfile TableWidth="640" TableBorder="0" and so forth - - How can I accomplish this with the SaveSetting/GetSetting scenario? "Elmo Watson" <sputnik@nospam.yahoo.com> wrote in message If you really must clutter the registry with crap that deosn't belongnews:%23ra9LGOgFHA.2444@tk2msftngp13.phx.gbl > How can I accomplish this with the SaveSetting/GetSetting scenario? there... savesetting "myapp","Table Settings\Basic","TableWidth","400" ?getsetting("myapp","Table Settings\Basic","TableWidth") 400 -- Reply to the group so all can participate VB.Net: "Fool me once..." > I'm trying to save Profiles in the registry, based on HTML table attributes. <snip>> > I've used the SaveSetting/GetSetting scenario for quite some time - and I > know how to do a pretty flat-style Setting - -hoever, I'm having a hard time > 'putting my head around' what I need here. > > Normally, I'd do something like this: > SaveSetting App.Title, "Settings", "OptionsTblBrdrWidth", iTableBorderWidth > > But, here - - I want to save (and get) a specific section ("Table > Settings"), then -- under that section, I need to save separate profiles, > based on the name of the profile - - Like Basic/Maroon/Blue, whatever, so > I'd like to get: > How can I accomplish this with the SaveSetting/GetSetting scenario? You can put in sub-paths within the Section parameter:'*** Call SaveSetting(App.Title, "Settings\" & CurrentUser, "OptionsTblBrdrWidth", iTableBorderWidth) '*** Get/SaveSetting() only gives you very basic registry access though, for more flexibility (including being able to store numeric rather than just string values) you would need to use the API to access the registry. You can however grab the Registry class from vbaccelerator.com which wraps the API calls and makes them a lot easier to use. Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ I must have been going at this the wrong way - -
that works great - - thanks! - - however, now, that I want to populate a combobox with the profile names, GetAllSettings doesn't work..... So - how can I traverse the profiles under Table Settings, getting the Text/name of the profile and add them to the combobox? Show quoteHide quote "Mike D Sutton" <ED***@mvps.org> wrote in message more flexibility (including being able to storenews:uTvtvROgFHA.1284@TK2MSFTNGP14.phx.gbl... > > I'm trying to save Profiles in the registry, based on HTML table attributes. > > > > I've used the SaveSetting/GetSetting scenario for quite some time - and I > > know how to do a pretty flat-style Setting - -hoever, I'm having a hard time > > 'putting my head around' what I need here. > > > > Normally, I'd do something like this: > > SaveSetting App.Title, "Settings", "OptionsTblBrdrWidth", iTableBorderWidth > > > > But, here - - I want to save (and get) a specific section ("Table > > Settings"), then -- under that section, I need to save separate profiles, > > based on the name of the profile - - Like Basic/Maroon/Blue, whatever, so > > I'd like to get: > <snip> > > How can I accomplish this with the SaveSetting/GetSetting scenario? > > You can put in sub-paths within the Section parameter: > > '*** > Call SaveSetting(App.Title, "Settings\" & CurrentUser, "OptionsTblBrdrWidth", iTableBorderWidth) > '*** > > Get/SaveSetting() only gives you very basic registry access though, for > numeric rather than just string values) you would need to use the API to access the registry. You can however grab the> Registry class from vbaccelerator.com which wraps the API calls and makes them a lot easier to use.Show quoteHide quote > Hope this helps, > > Mike > > > - Microsoft Visual Basic MVP - > E-Mail: ED***@mvps.org > WWW: Http://EDais.mvps.org/ > > > I must have been going at this the wrong way - - GetAllSettings() only enumerates values, not the keys themselves so you'd either need to store the list of profile names> > that works great - - thanks! - - > > however, now, that I want to populate a combobox with the profile names, > GetAllSettings doesn't work..... > > So - how can I traverse the profiles under Table Settings, getting the > Text/name of the profile and add them to the combobox? as a separate value under the Settings key or grab the afore mentioned registry class and perform a quick enumeration on the key: '*** Dim Profiles() As String, NumProfiles As Long Dim MyReg As cRegistry Set MyReg = New cRegistry MyReg.ClassKey = HKEY_CURRENT_USER MyReg.SectionKey = "Software\VB and VBA Program Settings\" & App.Title & "\Settings\" Call MyReg.EnumerateSections(Profiles(), NumProfiles) Set MyReg = Nothing '*** After that code is executed, NumProfiles stores the number of profiles under the key, and the Profiles() array contains a 1-dimensional array of their names. This for instance would print a list of all profiles and all values to the debug window (Ctrl+G): '*** Dim LoopProfiles As Long, LoopValues As Long Dim Values() As String, NumValues As Long Dim BaseKey As String BaseKey = MyReg.SectionKey For LoopProfiles = 1 To NumProfiles MyReg.SectionKey = BaseKey & Profiles(LoopProfiles) & "\" Call MyReg.EnumerateValues(Values(), NumValues) Debug.Print Profiles(LoopProfiles) & ":" For LoopValues = 1 To NumValues Debug.Print vbTab & Values(LoopValues) Next LoopValues Next LoopProfiles '*** Hope this helps, Mike - Microsoft Visual Basic MVP - E-Mail: ED***@mvps.org WWW: Http://EDais.mvps.org/ Thank you VERY much - - I've been programming all weekend and was stumped
here - - you've helped me save SO much time. "Mike D Sutton" <ED***@mvps.org> wrote in message either need to store the list of profile namesnews:euzj6KPgFHA.1444@TK2MSFTNGP10.phx.gbl... > > I must have been going at this the wrong way - - > > > > that works great - - thanks! - - > > > > however, now, that I want to populate a combobox with the profile names, > > GetAllSettings doesn't work..... > > > > So - how can I traverse the profiles under Table Settings, getting the > > Text/name of the profile and add them to the combobox? > > GetAllSettings() only enumerates values, not the keys themselves so you'd > as a separate value under the Settings key or grab the afore mentioned registry class and perform a quick enumeration onShow quoteHide quote > the key: under the key, and the Profiles() array contains> > '*** > Dim Profiles() As String, NumProfiles As Long > Dim MyReg As cRegistry > > Set MyReg = New cRegistry > MyReg.ClassKey = HKEY_CURRENT_USER > MyReg.SectionKey = "Software\VB and VBA Program Settings\" & App.Title & "\Settings\" > Call MyReg.EnumerateSections(Profiles(), NumProfiles) > Set MyReg = Nothing > '*** > > After that code is executed, NumProfiles stores the number of profiles > a 1-dimensional array of their names. debug window (Ctrl+G):> This for instance would print a list of all profiles and all values to the Show quoteHide quote > > '*** > Dim LoopProfiles As Long, LoopValues As Long > Dim Values() As String, NumValues As Long > Dim BaseKey As String > > BaseKey = MyReg.SectionKey > For LoopProfiles = 1 To NumProfiles > MyReg.SectionKey = BaseKey & Profiles(LoopProfiles) & "\" > Call MyReg.EnumerateValues(Values(), NumValues) > > Debug.Print Profiles(LoopProfiles) & ":" > > For LoopValues = 1 To NumValues > Debug.Print vbTab & Values(LoopValues) > Next LoopValues > Next LoopProfiles > '*** > > Hope this helps, > > Mike > > > - Microsoft Visual Basic MVP - > E-Mail: ED***@mvps.org > WWW: Http://EDais.mvps.org/ > >
Divide a path into a Drivename, Pathname, and Filename?
Definition of an implementation Return Security Events for Yesterday Resizing form Emergency: Unicode Characters in a Dataset. Time fired event, error out of stack space How 2 get data from a web form DOS box and ALT_ENTER VB Package Deployment Problem Enumerate Devices |
|||||||||||||||||||||||