Home All Groups Group Topic Archive Search About
Author
12 Sep 2006 12:12 PM
Gultekin Komanli
Hi All,

When I use "option strict on" the lines below are producing errors
("implicit conversion").


        chkMove.Checked = RegKey.GetValue(C_RK_MOVEFILES, False)
        txtUserName.Text = RegKey.GetValue(C_RK_USERNAME, "")

Is there any function like GetValueBoolean, GetValueString for reading
registry keys?

Or should I use CType for conversion ?


Cheers.
Gultekin.
--

Author
12 Sep 2006 1:03 PM
Marina Levit [MVP]
Yes, always keep it on.

And here, you are responsible for converting these values to the appropriate
types.  So you can use CType, or the more specialized CBool, CInt, CStr. You
can also do things like Int32.Parse or Int32.TryParse, to actually parse
strings as integers.
These conversions will fail if what you are getting from the registry cannot
be cast as the appropriate type.

You can just construct your own wrapper that has GetValueBoolean, and so on,
where you do all these conversions. Then you just call your own method,
which retrieves the registry key, does the appropriate conversion, checks if
it's empty, and so on.

Show quoteHide quote
"Gultekin Komanli" <gkoma***@gmail.com> wrote in message
news:%23ls9oSm1GHA.4816@TK2MSFTNGP06.phx.gbl...
> Hi All,
>
> When I use "option strict on" the lines below are producing errors
> ("implicit conversion").
>
>
>        chkMove.Checked = RegKey.GetValue(C_RK_MOVEFILES, False)
>        txtUserName.Text = RegKey.GetValue(C_RK_USERNAME, "")
>
> Is there any function like GetValueBoolean, GetValueString for reading
> registry keys?
>
> Or should I use CType for conversion ?
>
>
> Cheers.
> Gultekin.
> --
>
Author
12 Sep 2006 1:42 PM
Gultekin Komanli
Thank you.

Marina Levit [MVP] wrote:

Show quoteHide quote
> Yes, always keep it on.
>
> And here, you are responsible for converting these values to the
> appropriate types.  So you can use CType, or the more specialized
> CBool, CInt, CStr. You can also do things like Int32.Parse or
> Int32.TryParse, to actually parse strings as integers.  These
> conversions will fail if what you are getting from the registry
> cannot be cast as the appropriate type.
>
> You can just construct your own wrapper that has GetValueBoolean, and
> so on, where you do all these conversions. Then you just call your
> own method, which retrieves the registry key, does the appropriate
> conversion, checks if it's empty, and so on.
>
> "Gultekin Komanli" <gkoma***@gmail.com> wrote in message
> news:%23ls9oSm1GHA.4816@TK2MSFTNGP06.phx.gbl...
> > Hi All,
> >
> > When I use "option strict on" the lines below are producing errors
> > ("implicit conversion").
> >
> >
> >       chkMove.Checked = RegKey.GetValue(C_RK_MOVEFILES, False)
> >       txtUserName.Text = RegKey.GetValue(C_RK_USERNAME, "")
> >
> > Is there any function like GetValueBoolean, GetValueString for
> > reading registry keys?
> >
> > Or should I use CType for conversion ?
> >
> >
> > Cheers.
> > Gultekin.
> > -- 



--