473,320 Members | 2,080 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.

Does Option Strict On add overhead?

By turning Option Strict on, is there extra overhead? For example w/o it on
the following doesnt get flagged:
validxhtml.Attributes.Add("height", 22) but with it on the 22 is underlined
and the message is "Option Strict On disallows implicit conversions from
'Integer' to 'String'.". I then use validxhtml.Attributes.Add("height",
cstr(22)) and the blue squiggel goes away with strict on. By using cstr is
there extra overhead created?
Nov 17 '05 #1
2 2025
The CStr conversion happens whether you have Option Strict on or not.
So no there isn't any overhead.
The main difference is that with Option Strict On you are forced to do such
conversions explicity instead of relying on VB to do them automatically for
you.
While this requires a bit of extra work, it is considered to be well worth
it to help prevent unexpected runtime errors.
These kinds of bugs can be notoriously difficult to flush out and can be
very expensive to fix if they are discovered after an app is deployed. This
is why most good developers will tell you to always turn Option Strict on.

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
"Showjumper" <sh*******@grkjashdjkf.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
By turning Option Strict on, is there extra overhead? For example w/o it on the following doesnt get flagged:
validxhtml.Attributes.Add("height", 22) but with it on the 22 is underlined and the message is "Option Strict On disallows implicit conversions from
'Integer' to 'String'.". I then use validxhtml.Attributes.Add("height",
cstr(22)) and the blue squiggel goes away with strict on. By using cstr is
there extra overhead created?

Nov 17 '05 #2
Option Strict On causes no overhead.

In fact, it reduces the overhead caused by developers wondering why their
code didn't work, since it compiled ok.

In your example, why not use:

validxhtml.Attributes.Add("height", "22")

--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

"Showjumper" <sh*******@grkjashdjkf.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
By turning Option Strict on, is there extra overhead? For example w/o it on the following doesnt get flagged:
validxhtml.Attributes.Add("height", 22) but with it on the 22 is underlined and the message is "Option Strict On disallows implicit conversions from
'Integer' to 'String'.". I then use validxhtml.Attributes.Add("height",
cstr(22)) and the blue squiggel goes away with strict on. By using cstr is
there extra overhead created?

Nov 17 '05 #3

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

Similar topics

12
by: Simon Harris | last post by:
Hi All, I've been advised to use option strict. I've tried to read up on this, all i can find is that it... "disallows implicit narrowing conversions" This kinda makes sense - Means I have...
13
by: Cor | last post by:
Hi Option Strict gurus, Because of the so much given advises here to use Option Strict I did try to use that. But it gives an error and I don't know how to resolve that. The message is that...
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....
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...
4
by: =?Utf-8?B?UGl0Rw==?= | last post by:
Here the facts as code sample: Public Class Class1 Sub ABC(ByVal item As IUnit) End Sub End Class Public Interface IUnit ' or any other Interface ReadOnly Property Heureka() As Activator...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
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.