borris83
Member
- Joined
- Apr 30, 2009
- Messages
- 23
- Programming Experience
- Beginner
I have the following for each loop which loops through a registry key and reads all the values:
What I am trying to have been highlighted in bold.. Each time the loop executes and reads a value from the registry, I want the code to create a checkbox which has a unique name and text according to the value that was read... So the number of checkboxes will depend on number of values that is got from the registry...
But this doesn't work. It only creates one text box and the text of the textbox is also incomplete...
Can u please tell me what is wrong?
VB.NET:
Dim returnValue As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run")
Dim keyname As String = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim values() As String = returnValue.GetValueNames
Dim value As String
Dim message As String = ""
For Each value In values
Dim readvalue As String
readvalue = Registry.GetValue(keyname, value, Nothing)
message &= value & " : " & readvalue & vbNewLine
[B] Dim chkb As New CheckBox
Dim chkboxname As String = "chkbox" & value
Dim text As String = value & " : " & readvalue
Me.Controls.Add(chkb)
chkb.Text = text
chkb.Name = chkboxname[/B]
Next
' for testing, comment this out
'messagebox.show (message)
What I am trying to have been highlighted in bold.. Each time the loop executes and reads a value from the registry, I want the code to create a checkbox which has a unique name and text according to the value that was read... So the number of checkboxes will depend on number of values that is got from the registry...
But this doesn't work. It only creates one text box and the text of the textbox is also incomplete...
Can u please tell me what is wrong?