Home All Groups Group Topic Archive Search About
Author
4 Jul 2005 9:46 PM
Elmo Watson
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:

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?

Author
4 Jul 2005 9:59 PM
Bob Butler
"Elmo Watson" <sputnik@nospam.yahoo.com> wrote in message
news:%23ra9LGOgFHA.2444@tk2msftngp13.phx.gbl
> How can I accomplish this with the SaveSetting/GetSetting scenario?

If you really must clutter the registry with crap that deosn't belong
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..."
Author
4 Jul 2005 10:05 PM
Mike D Sutton
> 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 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/
Author
4 Jul 2005 10:57 PM
Elmo Watson
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
news: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
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.
Show quoteHide quote
> Hope this helps,
>
>     Mike
>
>
>  - Microsoft Visual Basic MVP -
> E-Mail: ED***@mvps.org
> WWW: Http://EDais.mvps.org/
>
>
Author
4 Jul 2005 11:47 PM
Mike D Sutton
> 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 either need to store the list of profile names
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/
Author
5 Jul 2005 12:16 AM
Elmo Watson
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
news: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
either need to store the list of profile names
> as a separate value under the Settings key or grab the afore mentioned
registry class and perform a quick enumeration on
Show quoteHide quote
> 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):
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/
>
>