Re: Wish I was using .net
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam>
- Date: Wed, 22 Feb 2006 05:27:29 GMT
With "Option Strict On", the VB 2005 compiler won't allow your code. It
gives the warning "Option Strict On disallows implicit conversions from
'Double' to 'Long'. With Option Strict Off, the compiler accepts this. Set
your project defaults to "Option Strict On" and also have the compiler treat
all warnings as errors.
Mike Ober.
"Michael C" <nospam@xxxxxxxxxx> wrote in message
news:OvciDqpNGHA.2336@xxxxxxxxxxxxxxxxxxxxxxx
"MikeD" <nobody@xxxxxxxxxxx> wrote in messagefunction.
news:%23mUN6poNGHA.2624@xxxxxxxxxxxxxxxxxxxxxxx
That IS unfortunate. Perhaps better testing is in order?
One other thing I forgot to mention is that the bug might not appear as
runtime error but a subtle bug instead. For example:
dim dblRate as double, dblHours as double
'get rate and hours from db
msgBox GetPay(dblRate, dblHours)
function GetPay(dblRate as double, dblHours as long) as double
GetPay = dblRate * dblHours
end function
Notice that dblHours has been accidentally declared as long in the
Dotnet will allow the function to compile because there is no loss of datatesting.
but when the function is called it will give an error saying it cannot
implicitly convert a double to a long. If the programmer intended for the
conversion then they'll explicitly cast it there, if they didn't then
they'll fix it immediately, saving the trouble of finding it during
complex
This is a fairly simple example and would be very hard to find in a
payroll system, especially if it only applied to some sort of special
payment that occured rarely.
Michael
.
- Follow-Ups:
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- References:
- Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: MikeD
- Re: Wish I was using .net
- From: Michael C
- Re: Wish I was using .net
- From: MikeD
- Re: Wish I was using .net
- From: Michael C
- Wish I was using .net
- Prev by Date: Re: Wish I was using .net
- Next by Date: Re: Why won't VB6 control set install on WinXP pro SP2?
- Previous by thread: Re: Wish I was using .net
- Next by thread: Re: Wish I was using .net
- Index(es):
Relevant Pages
|
Loading