473,320 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Registry enigma - please help!

Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:

Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:

key.SetValue("lstNSXitems", lstNSX.Items)

where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:

If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If

All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.

Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.

Thanks for any help. I'm really stumped on this one.
Oct 1 '06 #1
6 1654
Although you can place an object into the registry and retreive it

Actually, it seems to just store Object.ToString() into the registry,
not the object itself.

Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:

Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")

Thanks,

Seth Rowe

JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:

Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:

key.SetValue("lstNSXitems", lstNSX.Items)

where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:

If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If

All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.

Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.

Thanks for any help. I'm really stumped on this one.
Oct 1 '06 #2
Thanks Seth,

I'm new to VB2005 and came from VBA, so my depth of knowledge is not that
deep. The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.

It seems like a lot of extra code if the SetValue registry takes an object.
But, I am relatively new to programming in VB2005. Do you think the above
methods are okay, or is there a simpler way?

Thanks for all your help! I greatly appreciate it.

"rowe_newsgroups" wrote:
Although you can place an object into the registry and retreive it

Actually, it seems to just store Object.ToString() into the registry,
not the object itself.

Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:

Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")

Thanks,

Seth Rowe

JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:

Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:

key.SetValue("lstNSXitems", lstNSX.Items)

where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:

If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If

All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.

Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.

Thanks for any help. I'm really stumped on this one.

Oct 2 '06 #3
The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.
Um, not sure if I understand you completely. Basically, you want to use
the registry to store values that will be used to populate a listbox
right?
I thought about using a loop along with the CreateSubTree method to create a
registry entry for each item in the list.
What's the "CreateSubTree" method? Also, what is the list that holds
the values you want to write to the registry.

Sorry for all the questions, I'm trying to figure out what exactly
you're doing before I make any suggestions.

Thanks,

Seth Rowe

JOSII wrote:
Thanks Seth,

I'm new to VB2005 and came from VBA, so my depth of knowledge is not that
deep. The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.

It seems like a lot of extra code if the SetValue registry takes an object.
But, I am relatively new to programming in VB2005. Do you think the above
methods are okay, or is there a simpler way?

Thanks for all your help! I greatly appreciate it.

"rowe_newsgroups" wrote:
Although you can place an object into the registry and retreive it
Actually, it seems to just store Object.ToString() into the registry,
not the object itself.

Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:

Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")

Thanks,

Seth Rowe

JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:
>
Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:
>
key.SetValue("lstNSXitems", lstNSX.Items)
>
where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:
>
If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If
>
All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.
>
Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.
>
Thanks for any help. I'm really stumped on this one.
Oct 2 '06 #4
Hi Seth,

I finally figured it out. Here is what I have:

One form with two ListBoxes, each of which allows drag and drop
functionality. The left side ListBox is originally populated with 10 items
from a hard-coded ArrayList. the right side ListBox is initially empty.

The problem was to have persistence of the items remaining in both boxes
when the form closed and when the application closed. I couldn't use a config
file, so I used the registry.

Here is the way data to the ListBoxes operate:

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

'get registry info to apply the last form position
FormSettings.ApplySettings(Me)

If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
Dim vc2Count As Integer = keyNSX.ValueCount
If vc1Count = 0 And vc2Count = 0 Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F",
"G", "H", _
"I", "J"})
Else
For Each valueName As String In keyNS.GetValueNames()
Me.lstNS.Items.Add(keyNS.GetValue(valueName))
Next
End If
End If
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count = 0 Then

Else
For Each valueName As String In keyNSX.GetValueNames()
Me.lstNSX.Items.Add(keyNSX.GetValue(valueName))
Next
End If
End If

End Sub

Private Sub NSNST_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

FormSettings.SaveSettings(Me)

'first, delete the subkey and all subkeys if they exist
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count 0 Then
Dim sk2Name As String = ""
For Each sk2Name In keyNSX.GetValueNames()
keyNSX.DeleteValue(sk2Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsxCount As Integer = 0
For nsxCount = 0 To lstNSX.Items.Count - 1
keyNSX.SetValue("NSXitem" & nsxCount.ToString,
lstNSX.Items(nsxCount).ToString)
Next
keyNSX.Close()

'first, delete the subkey and all subkeys if they exist
If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
If vc1Count 0 Then
Dim sk1Name As String = ""
For Each sk1Name In keyNS.GetValueNames()
keyNS.DeleteValue(sk1Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsCount As Integer = 0
For nsCount = 0 To lstNS.Items.Count - 1
keyNS.SetValue("NSitem" & nsCount.ToString,
lstNS.Items(nsCount).ToString)
Next
keyNS.Close()

End Sub

I was using the Microsoft.Win32.RegistryKey methods to achieve it. It took
me too long to figure it out, though. I learn much better through classroom
interaction and one on one than through a book. This medium is very helpful,
too, when someone else has already tackled the problem. I must have 6 books
on VB2005, and none of them get into the registry as much as I think they
should(IMHO). :)

Thanks for helping, Seth. I greatly appreciate it.

Best regards,

JOSII

"rowe_newsgroups" wrote:
The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.

Um, not sure if I understand you completely. Basically, you want to use
the registry to store values that will be used to populate a listbox
right?
I thought about using a loop along with the CreateSubTree method to create a
registry entry for each item in the list.

What's the "CreateSubTree" method? Also, what is the list that holds
the values you want to write to the registry.

Sorry for all the questions, I'm trying to figure out what exactly
you're doing before I make any suggestions.

Thanks,

Seth Rowe

JOSII wrote:
Thanks Seth,

I'm new to VB2005 and came from VBA, so my depth of knowledge is not that
deep. The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.

It seems like a lot of extra code if the SetValue registry takes an object.
But, I am relatively new to programming in VB2005. Do you think the above
methods are okay, or is there a simpler way?

Thanks for all your help! I greatly appreciate it.

"rowe_newsgroups" wrote:
Although you can place an object into the registry and retreive it
>
Actually, it seems to just store Object.ToString() into the registry,
not the object itself.
>
Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:
>
Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")
>
Thanks,
>
Seth Rowe
>
JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:

Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:

key.SetValue("lstNSXitems", lstNSX.Items)

where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:

If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If

All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.

Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.

Thanks for any help. I'm really stumped on this one.
>
>

Oct 3 '06 #5
I must have 6 books on VB2005, and none of them get into the registry as much as I think they should(IMHO). :)

Popular opinion seems to be against using the registry now a days.
Personnally I like using XML files instead of both registry setting and
ini files. Not only can they be easier to use (sometimes) but it also
gets you familar with a format that you will run into in various
projects. There are quite a few great suggestions on using XML archived
in this news group, you should do some quick searches for them if
you're interested. Most are based on serializable classes (like Cor's
post on using datasets) others use the XML document object in the
System.XML namespace to read/write XML files.

Thanks,

Seth Rowe

JOSII wrote:
Hi Seth,

I finally figured it out. Here is what I have:

One form with two ListBoxes, each of which allows drag and drop
functionality. The left side ListBox is originally populated with 10 items
from a hard-coded ArrayList. the right side ListBox is initially empty.

The problem was to have persistence of the items remaining in both boxes
when the form closed and when the application closed. I couldn't use a config
file, so I used the registry.

Here is the way data to the ListBoxes operate:

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

'get registry info to apply the last form position
FormSettings.ApplySettings(Me)

If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
Dim vc2Count As Integer = keyNSX.ValueCount
If vc1Count = 0 And vc2Count = 0 Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F",
"G", "H", _
"I", "J"})
Else
For Each valueName As String In keyNS.GetValueNames()
Me.lstNS.Items.Add(keyNS.GetValue(valueName))
Next
End If
End If
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count = 0 Then

Else
For Each valueName As String In keyNSX.GetValueNames()
Me.lstNSX.Items.Add(keyNSX.GetValue(valueName))
Next
End If
End If

End Sub

Private Sub NSNST_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

FormSettings.SaveSettings(Me)

'first, delete the subkey and all subkeys if they exist
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count 0 Then
Dim sk2Name As String = ""
For Each sk2Name In keyNSX.GetValueNames()
keyNSX.DeleteValue(sk2Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsxCount As Integer = 0
For nsxCount = 0 To lstNSX.Items.Count - 1
keyNSX.SetValue("NSXitem" & nsxCount.ToString,
lstNSX.Items(nsxCount).ToString)
Next
keyNSX.Close()

'first, delete the subkey and all subkeys if they exist
If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
If vc1Count 0 Then
Dim sk1Name As String = ""
For Each sk1Name In keyNS.GetValueNames()
keyNS.DeleteValue(sk1Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsCount As Integer = 0
For nsCount = 0 To lstNS.Items.Count - 1
keyNS.SetValue("NSitem" & nsCount.ToString,
lstNS.Items(nsCount).ToString)
Next
keyNS.Close()

End Sub

I was using the Microsoft.Win32.RegistryKey methods to achieve it. It took
me too long to figure it out, though. I learn much better through classroom
interaction and one on one than through a book. This medium is very helpful,
too, when someone else has already tackled the problem. I must have 6 books
on VB2005, and none of them get into the registry as much as I think they
should(IMHO). :)

Thanks for helping, Seth. I greatly appreciate it.

Best regards,

JOSII

"rowe_newsgroups" wrote:
The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.
Um, not sure if I understand you completely. Basically, you want to use
the registry to store values that will be used to populate a listbox
right?
I thought about using a loop along with the CreateSubTree method to create a
registry entry for each item in the list.
What's the "CreateSubTree" method? Also, what is the list that holds
the values you want to write to the registry.

Sorry for all the questions, I'm trying to figure out what exactly
you're doing before I make any suggestions.

Thanks,

Seth Rowe

JOSII wrote:
Thanks Seth,
>
I'm new to VB2005 and came from VBA, so my depth of knowledge is not that
deep. The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.
>
It seems like a lot of extra code if the SetValue registry takes an object.
But, I am relatively new to programming in VB2005. Do you think the above
methods are okay, or is there a simpler way?
>
Thanks for all your help! I greatly appreciate it.
>
"rowe_newsgroups" wrote:
>
Although you can place an object into the registry and retreive it

Actually, it seems to just store Object.ToString() into the registry,
not the object itself.

Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:

Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")

Thanks,

Seth Rowe

JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:
>
Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:
>
key.SetValue("lstNSXitems", lstNSX.Items)
>
where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:
>
If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If
>
All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.
>
Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.
>
Thanks for any help. I'm really stumped on this one.
Oct 3 '06 #6
Thanks Seth,

I do remember seeing something about "serializable" in my readings, but I
think it may have been in reference to config files. I understand the basic
logic concerning the construction of an XML file, but I'm not at all familiar
with how to construct one or how to convert, let's say, a string array into
an XML file and then read it again when needed.

If I could learn that, it would likely solve a lot of problems. I don't
like to use the registry unless necessary, because it can me messy and cause
problems. It's just not a very clean way to do things.

Thanks for all your suggestions - they are very good. :)

Best regards,

JOSII

"rowe_newsgroups" wrote:
I must have 6 books on VB2005, and none of them get into the registry as much as I think they should(IMHO). :)

Popular opinion seems to be against using the registry now a days.
Personnally I like using XML files instead of both registry setting and
ini files. Not only can they be easier to use (sometimes) but it also
gets you familar with a format that you will run into in various
projects. There are quite a few great suggestions on using XML archived
in this news group, you should do some quick searches for them if
you're interested. Most are based on serializable classes (like Cor's
post on using datasets) others use the XML document object in the
System.XML namespace to read/write XML files.

Thanks,

Seth Rowe

JOSII wrote:
Hi Seth,

I finally figured it out. Here is what I have:

One form with two ListBoxes, each of which allows drag and drop
functionality. The left side ListBox is originally populated with 10 items
from a hard-coded ArrayList. the right side ListBox is initially empty.

The problem was to have persistence of the items remaining in both boxes
when the form closed and when the application closed. I couldn't use a config
file, so I used the registry.

Here is the way data to the ListBoxes operate:

Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

'get registry info to apply the last form position
FormSettings.ApplySettings(Me)

If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
Dim vc2Count As Integer = keyNSX.ValueCount
If vc1Count = 0 And vc2Count = 0 Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F",
"G", "H", _
"I", "J"})
Else
For Each valueName As String In keyNS.GetValueNames()
Me.lstNS.Items.Add(keyNS.GetValue(valueName))
Next
End If
End If
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count = 0 Then

Else
For Each valueName As String In keyNSX.GetValueNames()
Me.lstNSX.Items.Add(keyNSX.GetValue(valueName))
Next
End If
End If

End Sub

Private Sub NSNST_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

FormSettings.SaveSettings(Me)

'first, delete the subkey and all subkeys if they exist
If Not keyNSX Is Nothing Then
Dim vc2Count As Integer = keyNSX.ValueCount
If vc2Count 0 Then
Dim sk2Name As String = ""
For Each sk2Name In keyNSX.GetValueNames()
keyNSX.DeleteValue(sk2Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsxCount As Integer = 0
For nsxCount = 0 To lstNSX.Items.Count - 1
keyNSX.SetValue("NSXitem" & nsxCount.ToString,
lstNSX.Items(nsxCount).ToString)
Next
keyNSX.Close()

'first, delete the subkey and all subkeys if they exist
If Not keyNS Is Nothing Then
Dim vc1Count As Integer = keyNS.ValueCount
If vc1Count 0 Then
Dim sk1Name As String = ""
For Each sk1Name In keyNS.GetValueNames()
keyNS.DeleteValue(sk1Name)
Next
End If
End If

' Create data for the NSNST subkey.
Dim nsCount As Integer = 0
For nsCount = 0 To lstNS.Items.Count - 1
keyNS.SetValue("NSitem" & nsCount.ToString,
lstNS.Items(nsCount).ToString)
Next
keyNS.Close()

End Sub

I was using the Microsoft.Win32.RegistryKey methods to achieve it. It took
me too long to figure it out, though. I learn much better through classroom
interaction and one on one than through a book. This medium is very helpful,
too, when someone else has already tackled the problem. I must have 6 books
on VB2005, and none of them get into the registry as much as I think they
should(IMHO). :)

Thanks for helping, Seth. I greatly appreciate it.

Best regards,

JOSII

"rowe_newsgroups" wrote:
The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.
>
Um, not sure if I understand you completely. Basically, you want to use
the registry to store values that will be used to populate a listbox
right?
>
I thought about using a loop along with the CreateSubTree method to create a
registry entry for each item in the list.
>
What's the "CreateSubTree" method? Also, what is the list that holds
the values you want to write to the registry.
>
Sorry for all the questions, I'm trying to figure out what exactly
you're doing before I make any suggestions.
>
Thanks,
>
Seth Rowe
>
JOSII wrote:
Thanks Seth,

I'm new to VB2005 and came from VBA, so my depth of knowledge is not that
deep. The object is an ArrayList. I chose that to facilitate using a listbox
for drag and drop on the form. I thought about using a loop along with the
CreateSubTree method to create a registry entry for each item in the list. To
get the items back, I thought I'd use the SubKeyCount and GetValue inside
another loop.

It seems like a lot of extra code if the SetValue registry takes an object.
But, I am relatively new to programming in VB2005. Do you think the above
methods are okay, or is there a simpler way?

Thanks for all your help! I greatly appreciate it.

"rowe_newsgroups" wrote:

Although you can place an object into the registry and retreive it
>
Actually, it seems to just store Object.ToString() into the registry,
not the object itself.
>
Maybe you could just loop through your array and build a string like
"A,B,C,D,E,F,G,H,I,J" and then save that into the registry? Then just
use something like the following to put it back into an array:
>
Dim MyString as String = key.GetValue("lstNSXitems")
Dim MyArray() as String = MyString.Split(",")
>
Thanks,
>
Seth Rowe
>
JOSII wrote:
Getting a string of boolean value into and out of the registry is no problem.
Here's the problem:

Although you can place an object into the registry and retreive it, I need
to place an ArrayList object with 10 string items into the registry and
retreive them later. I tried this:

key.SetValue("lstNSXitems", lstNSX.Items)

where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
ArrayList with the 10 items. To retreive the ArrayList, I used this:

If key.GetValue("lstNSXitems") Is Nothing Then
Me.lstNS.Items.AddRange(New Object() {"A", "B", "C", "D", _
"E", "F", "G", "H", _
"I", "J"})
Else
Me.lstNSX.Items.AddRange(New Object()
{key.GetValue("lstNSXitems")})
End If

All this does is place "System.Windows.Forms.ListBox+ObjectCollection " into
the ArrayList on the form.

Can anyone tell me where my logic went south? I don't know if I messed up
the beginning, the end or both.

Thanks for any help. I'm really stumped on this one.
>
>
>
>

Oct 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: firenet | last post by:
Came in one morning and found that the following message appeared only on running Access 2000, then the program shuts down, all other office 2000 applications work fine. "Required registry...
21
by: Kevin Swanson | last post by:
I'm attempting some remote registry manipulation via C#. I've written a test app to simply grab a specified key from a specified hive on a specified machine. The call to OpenSubKey is throwing...
8
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
3
by: Mark Findlay | last post by:
When programming reads of the Windows Registry, do the registry keys and values need to be localized for international use? For example, do I need to convert the key name...
5
by: Parv | last post by:
I am working in a domain environment. I am on a client machine and wants to edit registery of domain server. I am currently in a Domain user account and member of Domain administrators on the...
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
9
by: Newbie Coder | last post by:
Hello Newsgroup Readers I would like to know how to go & do the following: I have a certain registry key that has sub values Example: Key1 http://www.microsoft.com Key2 ...
4
pritipshah
by: pritipshah | last post by:
Hello All, I want to Access Registry from PHP script. I had sreach on net and I got Class for this which is as below. <?php class Registry { private $vars = array();...
11
by: Unknown Hero | last post by:
Tim Golden wrote: The first link which points to the Python documentation for the _winreg module I already checked, even before coming here. I am wondering how I should do the loop I need (go...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.