ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop, reading registry settings (https://www.excelbanter.com/excel-programming/399884-loop-reading-registry-settings.html)

Rick S.

Loop, reading registry settings
 
In the code below I have many "Keys" that will share the same value as the
"Setting" in the Registry.
Example:
ADMCustomerList (Appname), Customers (Section), Number1 (Key), Number1
(Setting).
What I see happening is I am retrieving both "Section" and "Key" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Section" and "1" is the "Key". A "0"
should skip the "Section" value and the following numeric value is the
corrosponding "Key" value location, IE, 1 thru 10 or 1 thru some number.

How can I read only the"Key" values?

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, intSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList", section:="Customers")
For intSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(intSettings, 0), sCustomer(intSettings, 1)
Next intSettings
For Each c In sCustomer
..AddItem c
Next
End With
'=============
--
Regards

Rick
XP Pro
Office 2007


Rick S.

Loop, reading registry settings
 
What I see happening is I am retrieving both "Section" and "Key" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Section" and "1" is the "Key". A "0"
should skip the "Section" value and the following numeric value is the
corrosponding "Key" value location, IE, 1 thru 10 or 1 thru some number.

Should read:

What I see happening is I am retrieving both "Key" and "Key Value" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Key" and "1" is the "Key Value". A
"0"
should skip the "Key" value and the following numeric value is the
corrosponding "Key Value" value location, IE, 1 thru 10 or 1 thru some number.

--
Regards

Rick
XP Pro
Office 2007



"Rick S." wrote:

In the code below I have many "Keys" that will share the same value as the
"Setting" in the Registry.
Example:
ADMCustomerList (Appname), Customers (Section), Number1 (Key), Number1
(Setting).
What I see happening is I am retrieving both "Section" and "Key" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Section" and "1" is the "Key". A "0"
should skip the "Section" value and the following numeric value is the
corrosponding "Key" value location, IE, 1 thru 10 or 1 thru some number.

How can I read only the"Key" values?

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, intSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList", section:="Customers")
For intSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(intSettings, 0), sCustomer(intSettings, 1)
Next intSettings
For Each c In sCustomer
.AddItem c
Next
End With
'=============
--
Regards

Rick
XP Pro
Office 2007


Rick S.

Loop, reading registry settings
 
With a lot of trial and error, I eventually stumbled onto a resolution. See
the following updated code.

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, iSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList",
section:="Customers")
For iSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(iSettings, 0), sCustomer(iSettings, 1)
Next iSettings
For Each c In sCustomer
If c = False Then
GoTo EndIt
Else
.AddItem c
End If
Next
End With
EndIt:
'=============

I found out there is a point when reading the array there is a value that
equals False, this appears to be the end of reading either the Key or Setting
values. In my case both values would be the same name so I can end reading
once c = False.

--
Regards

Rick
XP Pro
Office 2007



"Rick S." wrote:

In the code below I have many "Keys" that will share the same value as the
"Setting" in the Registry.
Example:
ADMCustomerList (Appname), Customers (Section), Number1 (Key), Number1
(Setting).
What I see happening is I am retrieving both "Section" and "Key" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Section" and "1" is the "Key". A "0"
should skip the "Section" value and the following numeric value is the
corrosponding "Key" value location, IE, 1 thru 10 or 1 thru some number.

How can I read only the"Key" values?

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, intSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList", section:="Customers")
For intSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(intSettings, 0), sCustomer(intSettings, 1)
Next intSettings
For Each c In sCustomer
.AddItem c
Next
End With
'=============
--
Regards

Rick
XP Pro
Office 2007


Rick S.

Loop, reading registry settings
 
Ignore this post!
I have screwed this up beyond belief.

--
Regards

Rick
XP Pro
Office 2007



"Rick S." wrote:

With a lot of trial and error, I eventually stumbled onto a resolution. See
the following updated code.

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, iSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList",
section:="Customers")
For iSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(iSettings, 0), sCustomer(iSettings, 1)
Next iSettings
For Each c In sCustomer
If c = False Then
GoTo EndIt
Else
.AddItem c
End If
Next
End With
EndIt:
'=============

I found out there is a point when reading the array there is a value that
equals False, this appears to be the end of reading either the Key or Setting
values. In my case both values would be the same name so I can end reading
once c = False.

--
Regards

Rick
XP Pro
Office 2007



"Rick S." wrote:

In the code below I have many "Keys" that will share the same value as the
"Setting" in the Registry.
Example:
ADMCustomerList (Appname), Customers (Section), Number1 (Key), Number1
(Setting).
What I see happening is I am retrieving both "Section" and "Key" values but
I do not know how to separate them in my code.

The variable "sCustomer" is used like "sCustomer(0, 1)" which would report
the first item in the list, "0" is the "Section" and "1" is the "Key". A "0"
should skip the "Section" value and the following numeric value is the
corrosponding "Key" value location, IE, 1 thru 10 or 1 thru some number.

How can I read only the"Key" values?

'===========
With ListBox1
Dim c As Variant
Dim sCustomer As Variant, intSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList", section:="Customers")
For intSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
Debug.Print sCustomer(intSettings, 0), sCustomer(intSettings, 1)
Next intSettings
For Each c In sCustomer
.AddItem c
Next
End With
'=============
--
Regards

Rick
XP Pro
Office 2007


Rick S.

Loop, reading registry settings
 
I beleive I found a working resolution!

'===========
With ListBox1
..Clear
Dim c As Variant
Dim x As String 'add this variable 10.26.07<<<<
Dim sCustomer As Variant, iSettings As Integer
sCustomer = GetAllSettings(appname:="ADMCustomerList",
section:="Customers")
For iSettings = LBound(sCustomer, 1) To UBound(sCustomer, 1)
x = sCustomer(iSettings, 0) 'modified this line 10.26.07<<<<
'MsgBox x 'for testing
.AddItem x 'added this line 10.26.07<<<<
Next iSettings
'Removed 2 lines of code here 10.26.07<<<<
End With
'=============

--
Regards

Rick
XP Pro
Office 2007


All times are GMT +1. The time now is 04:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com