|
-
Jan 1st, 2012, 01:49 PM
#1
Thread Starter
Hyperactive Member
read from registry key multi-string value ?
Hi,
I have made this code and it does work with a normal string key, but with a multi-string value(REG_MULTI_SZ) key it does not :/
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim readValue As String
readValue = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\test", "test123", Nothing)
For Each itemD As String In readValue
ListBox1.Items.Add(itemD)
Next
End Sub
The error is this : Conversion from type 'String()' to type 'String' is not valid.
So how do i read from a multi-tring value registry key and list is all into the listbox ?
Thanks
-
Jan 1st, 2012, 02:02 PM
#2
Re: read from registry key multi-string value ?
Do you have Option Strict On? I'm going to guess not. The value you get from GetValue is an object. You're implicitly converting an object to a string. Which is most likely the problem. If you cast the object to a string, then it should work.
Last edited by weirddemon; Jan 1st, 2012 at 02:06 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
-
Jan 1st, 2012, 02:06 PM
#3
Thread Starter
Hyperactive Member
Re: read from registry key multi-string value ?
 Originally Posted by weirddemon
Do you have Option Strict On? I'm going to guess not.
Makes no difference, same error :/
but if i use a normal registry key then it works fine, just not with mutli-string value
Thanks
-
Jan 1st, 2012, 02:12 PM
#4
Re: read from registry key multi-string value ?
You should always keep Option Strict on as a good programming practice and to avoid possible mistakes later on.
In the case of this issue, it's because a multi-string registry value is returned as an array. But you're not treating it as such.
I did this which allowed me to find an example by JMC here. It took about 10 seconds to do so. Although I haven't tried the example myself, it looks fairly solid.
*Edit: It works fine. Please do a little research next time before posting a question. It helps eliminate clutter such as this.
Last edited by weirddemon; Jan 1st, 2012 at 02:16 PM.
CodeBank contributions: Process Manager, Temp File Cleaner
 Originally Posted by SJWhiteley
"game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|