473,383 Members | 1,877 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,383 software developers and data experts.

option strict on !?

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.
--

Sep 12 '06 #1
2 927
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" <gk******@gmail.comwrote in message
news:%2****************@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.
--

Sep 12 '06 #2
Thank you.

Marina Levit [MVP] wrote:
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" <gk******@gmail.comwrote in message
news:%2****************@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.
--


--

Sep 12 '06 #3

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

Similar topics

9
by: Microsoft News | last post by:
I have a project that was created all with Option Strict OFF. Works great, not a problem with it. But if I turn Option Strict ON then I get a LOT of errors. My question, should I even care...
11
by: Daylor | last post by:
hi. im using option strict on. im doing in ,from the simple reason ,to be warn when there are implict conversion like string to int ,int to string. BUT. the price ,(now i see ), is very bad....
8
by: Rich | last post by:
Hello, If I leave Option Strict Off I can use the following syntax to read data from a Lotus Notes application (a NotesViewEntry object represents a row of data from a Lotus Notes View - like a...
17
by: David | last post by:
Hi all, I have the following problem: my program works fine, but when I add option strict at the top of the form, the following sub fails with an error that option strict does not allow late...
15
by: guy | last post by:
when i first started using .net (beta 1) i came across option strict and thought hey this could be really good, and since then have always turned it on, most people here seem to agree that this is...
13
by: C. Moya | last post by:
I fully expected the lack of a way to set Option Strict globally to be fixed in SP1. I can't seem to figure out if it has been fixed or not. It still seems we have to add the declaration at the top...
1
by: Jerad Rose | last post by:
I believe this issue is specific to ASP.NET. Why does VB.NET (2.0) ignore the project-level setting for Option Strict? I have the setting turned on in web.config: <compilation debug="true"...
18
by: Poldie | last post by:
How do I turn it on? I'm using vb 2005 in visual studio 2005 sp1. In my web.config I have: <compilation debug="true" strict="true" /> In my Tools/Options/Projects and solutions/vb defaults...
8
by: Rory Becker | last post by:
A wise man once said: "Never put off until runtime what you can fix at compile time." Actually I think he said it about 10 minutes before I started this post. I am a firm believer, like the...
8
by: =?Utf-8?B?R3JlZw==?= | last post by:
We have an application in our office that has the Option Strict option set to off right now. I do understand it should be set to ON, but right now, I'm just going to continue with it this way since...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

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.