I'm running into a very weird problem regarding subtraction.
Subtraction behaves as if it's an addition in the below sub
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
the discount mDisc was added to the total with the - operator!
Your help is greatly appreciated.
Bill
--------
Private Sub txtDiscount_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles txtDiscount.TextChanged
Dim mDisc, mRackc, mJaEc, mWfEC, mFactorAdj As Double
If IsNumeric(txtDiscount.Text) = True Then
mDisc = txtDiscount.Text
Else
mDisc = 0
End If
If IsNumeric(txtRackCost.Text) = True Then
mRackc = txtRackCost.Text
Else
mRackc = 0
End If
If IsNumeric(txtJacoEC.Text) = True Then
mJaEc = txtJacoEC.Text
Else
mJaEc = 0
End If
If IsNumeric(txtWfEC.Text) = True Then
mWfEC = txtWfEC.Text
Else
mWfEC = 0
End If
If IsNumeric(txtFactorAdjust.Text) = True Then
mFactorAdj = txtFactorAdjust.Text
Else
mFactorAdj = 0
End If
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
End Sub 16 1733
On Oct 17, 3:55 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
I'm running into a very weird problem regarding subtraction.
Subtraction behaves as if it's an addition in the below sub
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
the discount mDisc was added to the total with the - operator!
Your help is greatly appreciated.
Bill
--------
Private Sub txtDiscount_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles txtDiscount.TextChanged
Dim mDisc, mRackc, mJaEc, mWfEC, mFactorAdj As Double
If IsNumeric(txtDiscount.Text) = True Then
mDisc = txtDiscount.Text
Else
mDisc = 0
End If
If IsNumeric(txtRackCost.Text) = True Then
mRackc = txtRackCost.Text
Else
mRackc = 0
End If
If IsNumeric(txtJacoEC.Text) = True Then
mJaEc = txtJacoEC.Text
Else
mJaEc = 0
End If
If IsNumeric(txtWfEC.Text) = True Then
mWfEC = txtWfEC.Text
Else
mWfEC = 0
End If
If IsNumeric(txtFactorAdjust.Text) = True Then
mFactorAdj = txtFactorAdjust.Text
Else
mFactorAdj = 0
End If
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
End Sub
What was the value of mDisc? If it is a negative value, then it will
add... - a - equals a plus:
1 - -2 =
1 + +2 = 3
--
Tom Shelton
Tom;
It's a positive value.
I tested repeatedly.
I also have a similar problem with a bit value of 1 (true) is shown as -1 in
VS2005
Thanks
Bill
-----------
Below is my VS version info:
Microsoft Visual Studio 2005
Version 8.0.50727.762 (SP.050727-7600)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
Microsoft Visual Basic 2005 77626-009-0000007-41468
Microsoft Visual Basic 2005
Microsoft Visual C# 2005 77626-009-0000007-41468
Microsoft Visual C# 2005
Microsoft Visual C++ 2005 77626-009-0000007-41468
Microsoft Visual C++ 2005
Microsoft Visual J# 2005 77626-009-0000007-41468
Microsoft Visual J# 2005
Microsoft Visual Web Developer 2005 77626-009-0000007-41468
Microsoft Visual Web Developer 2005
Microsoft Web Application Projects 2005 77626-009-0000007-41468
Microsoft Web Application Projects 2005
Version 8.0.50727.762
Crystal Reports AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005
Microsoft Visual Studio 2005 Professional Edition - ENU Service Pack 1
(KB926601)
This service pack is for Microsoft Visual Studio 2005 Professional Edition -
ENU.
If you later install a more recent service pack, this service pack will be
uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/926601
Security Update for Microsoft Visual Studio 2005 Professional Edition - ENU
(KB937061)
This Security Update is for Microsoft Visual Studio 2005 Professional
Edition - ENU.
If you later install a more recent service pack, this Security Update will
be uninstalled automatically.
For more information, visit http://support.microsoft.com/kb/937061
SQL Server Analysis Services
Microsoft SQL Server Analysis Services Designer
Version 9.00.3042.00
SQL Server Integration Services
Microsoft SQL Server Integration Services Designer
Version 9.00.2047.00
SQL Server Reporting Services
Microsoft SQL Server Reporting Services Designers
Version 9.00.2047.00
"Tom Shelton" <to*********@comcast.netwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
On Oct 17, 3:55 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
>I'm running into a very weird problem regarding subtraction.
Subtraction behaves as if it's an addition in the below sub
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
the discount mDisc was added to the total with the - operator!
Your help is greatly appreciated.
Bill
--------
Private Sub txtDiscount_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtDiscount.TextChanged
Dim mDisc, mRackc, mJaEc, mWfEC, mFactorAdj As Double
If IsNumeric(txtDiscount.Text) = True Then
mDisc = txtDiscount.Text
Else
mDisc = 0
End If
If IsNumeric(txtRackCost.Text) = True Then
mRackc = txtRackCost.Text
Else
mRackc = 0
End If
If IsNumeric(txtJacoEC.Text) = True Then
mJaEc = txtJacoEC.Text
Else
mJaEc = 0
End If
If IsNumeric(txtWfEC.Text) = True Then
mWfEC = txtWfEC.Text
Else
mWfEC = 0
End If
If IsNumeric(txtFactorAdjust.Text) = True Then
mFactorAdj = txtFactorAdjust.Text
Else
mFactorAdj = 0
End If
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
End Sub
What was the value of mDisc? If it is a negative value, then it will
add... - a - equals a plus:
1 - -2 =
1 + +2 = 3
--
Tom Shelton
"Bill Nguyen" <bi*****************@jaco.comschrieb
Tom;
It's a positive value.
I tested repeatedly.
Please show us the exact line where the problem occurs and all the values in
all variables in the line.
I also have a similar problem with a bit value of 1 (true) is shown
as -1 in VS2005
You should switch Option Strict On
Armin
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
I also have a similar problem with a bit value of 1 (true) is shown as -1 in
VS2005
In these two expressions:
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj),
"0.#####0")
you're subtracting the sum of mDisc and another value from mRackc. In
this expression:
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
you're subtracting mDisc from mRackc, then adding mWfEC to the total.
I have no data with which I can test this, but I suspect you are
either missing a couple of parentheses in the last expression, or you
have too many in the first two.
Mark Lincoln
On Oct 17, 5:55 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
I'm running into a very weird problem regarding subtraction.
Subtraction behaves as if it's an addition in the below sub
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
the discount mDisc was added to the total with the - operator!
Your help is greatly appreciated.
Bill
--------
Private Sub txtDiscount_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles txtDiscount.TextChanged
Dim mDisc, mRackc, mJaEc, mWfEC, mFactorAdj As Double
If IsNumeric(txtDiscount.Text) = True Then
mDisc = txtDiscount.Text
Else
mDisc = 0
End If
If IsNumeric(txtRackCost.Text) = True Then
mRackc = txtRackCost.Text
Else
mRackc = 0
End If
If IsNumeric(txtJacoEC.Text) = True Then
mJaEc = txtJacoEC.Text
Else
mJaEc = 0
End If
If IsNumeric(txtWfEC.Text) = True Then
mWfEC = txtWfEC.Text
Else
mWfEC = 0
End If
If IsNumeric(txtFactorAdjust.Text) = True Then
mFactorAdj = txtFactorAdjust.Text
Else
mFactorAdj = 0
End If
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
End Sub
On Oct 17, 4:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
Tom;
It's a positive value.
I tested repeatedly.
I also have a similar problem with a bit value of 1 (true) is shown as -1 in
VS2005
Thanks
Bill
Bill,
First of all, I can tell you do not have option strict turned on.
Which is probably a bad idea, but that doesn't seem to be the root of
your problem:
' numbers i tested
mRackc = 100.0
mDisc = 5
mJaEc = 100.0
mWfEC = 100.0
mFactorAdj = 100.0
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
100 - (5 + 100) = 100 - 105 = -5
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
100 - 5 + 100 = 95 + 100 = 195
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj),
"0.#####0")
100 - (5 + 100) = 100 - 105 = -5
As far as I can tell, things are working correctly. What do you
expect the answers to be?
--
Tom Shelton
"Bill Nguyen" <bi*****************@jaco.comwrote in message
news:uM**************@TK2MSFTNGP04.phx.gbl...
I'm running into a very weird problem regarding subtraction.
Subtraction behaves as if it's an addition in the below sub
txtJacoCost.Text = Format(mRackc - (mDisc + mJaEc), "0.#####0")
txtWfCost.Text = Format(mRackc - mDisc + mWfEC, "0.#####0")
txtFactorCost.Text = Format(mRackc - (mDisc + mFactorAdj), "0.#####0")
the discount mDisc was added to the total with the - operator!
Your help is greatly appreciated.
Bill
--------
In the first and the third equations, if mJaEc or mFactorAdj are greater
than mDisc, then you will end up with a negative value inside the
parenthesis. If that happens, you will end up subtracting a negative number
from mRackc - which becomes an addition operation.
As for the second equation...
If you have a typo and accidentally left the parenthesis out, then the same
will apply to mWfEC.
Todd
Whoever told you that load of claptrap!!! It's information like that gives
people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is
the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type that
you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something
written in another .NET language.
If any conversion is required then then some form of 'middle-man' is invoked
to carry out any such conversions.
"Mark Lincoln" <ml******@earthlink.netwrote in message
news:11**********************@v29g2000prd.googlegr oups.com...
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
>I also have a similar problem with a bit value of 1 (true) is shown as -1 in VS2005
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it
in front of me, so I might be a bit hazy on the details. If you
really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote:
Whoever told you that load of claptrap!!! It's information like that gives
people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is
the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type that
you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something
written in another .NET language.
If any conversion is required then then some form of 'middle-man' is invoked
to carry out any such conversions.
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11**********************@v29g2000prd.googlegr oups.com...
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
I also have a similar problem with a bit value of 1 (true) is shown as -1
in
VS2005- Hide quoted text -
- Show quoted text -
Thanks all of you for helping me on this "weird math problem" thread.
1. It's stupid me. I put a wrong operator in a different sub and tried to
fix it in another sub! The formula is working properly.
2. Regarding the -1 as true, it has caused problem for me probably because I
did not set Strict = ON. When I did, the project gave me tons of errors that
I will have to fix line by line, so I don't know if it's a good thing to
switch it on.
Thanks again
Bill
"Mark Lincoln" <ml******@earthlink.netwrote in message
news:11*********************@t8g2000prg.googlegrou ps.com...
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it
in front of me, so I might be a bit hazy on the details. If you
really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote:
>Whoever told you that load of claptrap!!! It's information like that gives people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type that you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something written in another .NET language.
If any conversion is required then then some form of 'middle-man' is invoked to carry out any such conversions.
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11**********************@v29g2000prd.googleg roups.com...
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote: I also have a similar problem with a bit value of 1 (true) is shown as -1 in VS2005- Hide quoted text -
- Show quoted text -
It is an Extremely Good Thing to have STRICT ON. Yes it can be a pain
when you first turn it on, but some of those tons of errors you get
are real errors that need to be fixed.
On Thu, 18 Oct 2007 10:32:07 -0700, "Bill Nguyen"
<bi*****************@jaco.comwrote:
>Thanks all of you for helping me on this "weird math problem" thread.
1. It's stupid me. I put a wrong operator in a different sub and tried to fix it in another sub! The formula is working properly.
2. Regarding the -1 as true, it has caused problem for me probably because I did not set Strict = ON. When I did, the project gave me tons of errors that I will have to fix line by line, so I don't know if it's a good thing to switch it on.
Thanks again
Bill
"Mark Lincoln" <ml******@earthlink.netwrote in message news:11*********************@t8g2000prg.googlegro ups.com...
>Yes, you're correct: Casting a Boolean produces -1 for True in VB. However, .NET defines True as 1. VB passes CInt(True) as 1 to the .NET runtime and -1 within VB. Again, it's -1 within VB for compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it in front of me, so I might be a bit hazy on the details. If you really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote:
>>Whoever told you that load of claptrap!!! It's information like that gives people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type that you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something written in another .NET language.
If any conversion is required then then some form of 'middle-man' is invoked to carry out any such conversions.
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11**********************@v29g2000prd.google groups.com... VB uses -1 for True for compatibility with older versions of VB, but converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com> wrote: I also have a similar problem with a bit value of 1 (true) is shown as -1 in VS2005- Hide quoted text -
- Show quoted text -
I have to agree with Jack; Option Strict is the way to go. It can
keep you from making errors that result in posting to newsgroups for
answers. :)
On Oct 18, 1:32 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
Thanks all of you for helping me on this "weird math problem" thread.
1. It's stupid me. I put a wrong operator in a different sub and tried to
fix it in another sub! The formula is working properly.
2. Regarding the -1 as true, it has caused problem for me probably because I
did not set Strict = ON. When I did, the project gave me tons of errors that
I will have to fix line by line, so I don't know if it's a good thing to
switch it on.
Thanks again
Bill
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11*********************@t8g2000prg.googlegrou ps.com...
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it
in front of me, so I might be a bit hazy on the details. If you
really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote:
Whoever told you that load of claptrap!!! It's information like that
gives
people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is
the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type
that
you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something
written in another .NET language.
If any conversion is required then then some form of 'middle-man' is
invoked
to carry out any such conversions.
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
>news:11**********************@v29g2000prd.googleg roups.com...
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
I also have a similar problem with a bit value of 1 (true) is shown
as -1
in
VS2005- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
Do I have to fix these errors 1 by 1 or can I have a global fix?
Thanks again
Bill
"Mark Lincoln" <ml******@earthlink.netwrote in message
news:11**********************@q3g2000prf.googlegro ups.com...
>I have to agree with Jack; Option Strict is the way to go. It can
keep you from making errors that result in posting to newsgroups for
answers. :)
On Oct 18, 1:32 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote:
>Thanks all of you for helping me on this "weird math problem" thread.
1. It's stupid me. I put a wrong operator in a different sub and tried to fix it in another sub! The formula is working properly.
2. Regarding the -1 as true, it has caused problem for me probably because I did not set Strict = ON. When I did, the project gave me tons of errors that I will have to fix line by line, so I don't know if it's a good thing to switch it on.
Thanks again
Bill
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11*********************@t8g2000prg.googlegro ups.com...
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it
in front of me, so I might be a bit hazy on the details. If you
really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote: Whoever told you that load of claptrap!!! It's information like that gives people the wrong idea of how something works.
>BASIC (of which VB is a derivative) defines False as 0 (zero) but True is the result of a bitwise NOT of False (i.e, True = Not False).
>It is only when you attempt to cast a Boolean to another numeric type that you get a result of -1 for True which is demonstrated by:
> Dim _boolean As Boolean = False
> Dim _integer As Integer = Not Convert.ToInt32(_boolean)
> Console.Writeline(_integer)
>VB makes no conversions whatsover when you pass a Boolean to something written in another .NET language.
>If any conversion is required then then some form of 'middle-man' is invoked to carry out any such conversions.
>"Mark Lincoln" <mlinc...@earthlink.netwrote in message
>>news:11**********************@v29g2000prd.google groups.com...
VB uses -1 for True for compatibility with older versions of VB, but
converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com>
wrote: I also have a similar problem with a bit value of 1 (true) is shown as -1 in VS2005- Hide quoted text -
>- Show quoted text -- Hide quoted text -
- Show quoted text -
On Oct 18, 10:06 am, Mark Lincoln <mlinc...@earthlink.netwrote:
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
Yep - it was one of the stupid changes made in the Beta2 rollback
debacle. Before Beta2 VB.NET defined True = 1, but in a misguided
effort to maintain "compatability" they changed the behavior of
Boolean to the confusing mess it is today. The fact is, no one should
even care what the numeric value of a Boolean is - you should NEVER be
treating it as a number.
--
Tom Shelton
Sometimes multiple errors can be fixed by changing the type of a
property, method argument or function return value. Other times each
one needs to be changed. Without knowing what the errors are I can't
tell.
On Thu, 18 Oct 2007 12:56:41 -0700, "Bill Nguyen"
<bi*****************@jaco.comwrote:
>Do I have to fix these errors 1 by 1 or can I have a global fix?
Thanks again
Bill "Mark Lincoln" <ml******@earthlink.netwrote in message news:11**********************@q3g2000prf.googlegr oups.com...
>>I have to agree with Jack; Option Strict is the way to go. It can keep you from making errors that result in posting to newsgroups for answers. :)
On Oct 18, 1:32 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com> wrote:
>>Thanks all of you for helping me on this "weird math problem" thread.
1. It's stupid me. I put a wrong operator in a different sub and tried to fix it in another sub! The formula is working properly.
2. Regarding the -1 as true, it has caused problem for me probably because I did not set Strict = ON. When I did, the project gave me tons of errors that I will have to fix line by line, so I don't know if it's a good thing to switch it on.
Thanks again
Bill
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11*********************@t8g2000prg.googlegr oups.com... Yes, you're correct: Casting a Boolean produces -1 for True in VB. However, .NET defines True as 1. VB passes CInt(True) as 1 to the .NET runtime and -1 within VB. Again, it's -1 within VB for compatibility with older versions.
The information comes from Francisco Balena's book. I don't have it in front of me, so I might be a bit hazy on the details. If you really want me to, I'll quote him verbatim when I get the chance.
Mark Lincoln
On Oct 18, 12:05 am, "Stephany Young" <noone@localhostwrote: Whoever told you that load of claptrap!!! It's information like that gives people the wrong idea of how something works.
BASIC (of which VB is a derivative) defines False as 0 (zero) but True is the result of a bitwise NOT of False (i.e, True = Not False).
It is only when you attempt to cast a Boolean to another numeric type that you get a result of -1 for True which is demonstrated by:
Dim _boolean As Boolean = False
Dim _integer As Integer = Not Convert.ToInt32(_boolean)
Console.Writeline(_integer)
VB makes no conversions whatsover when you pass a Boolean to something written in another .NET language.
If any conversion is required then then some form of 'middle-man' is invoked to carry out any such conversions.
"Mark Lincoln" <mlinc...@earthlink.netwrote in message
news:11**********************@v29g2000prd.googl egroups.com...
VB uses -1 for True for compatibility with older versions of VB, but converts it to 1 when passing it to other .NET languages.
Mark Lincoln
On Oct 17, 6:56 pm, "Bill Nguyen" <billn_nospam_ple...@jaco.com> wrote: I also have a similar problem with a bit value of 1 (true) is shown as -1 in VS2005- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
Hear, hear! I can't remember where I first saw that sentiment, but
I've never counted on the numeric value of a Boolean ever since.
Mark Lincoln
On Oct 18, 4:25 pm, Tom Shelton <tom_shel...@comcast.netwrote:
On Oct 18, 10:06 am, Mark Lincoln <mlinc...@earthlink.netwrote:
Yes, you're correct: Casting a Boolean produces -1 for True in VB.
However, .NET defines True as 1. VB passes CInt(True) as 1 to
the .NET runtime and -1 within VB. Again, it's -1 within VB for
compatibility with older versions.
Yep - it was one of the stupid changes made in the Beta2 rollback
debacle. Before Beta2 VB.NET defined True = 1, but in a misguided
effort to maintain "compatability" they changed the behavior of
Boolean to the confusing mess it is today. The fact is, no one should
even care what the numeric value of a Boolean is - you should NEVER be
treating it as a number.
--
Tom Shelton
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Francois |
last post by:
Salut - Hello,
I'm trying to comply with W3C HTML 4.01 Strict standards BUT one JS code is
causing me troubles. The parser returns an error of "having a closure tag
</a> with no other tag open...
|
by: Protoman |
last post by:
I keep getting -1#INF from this code; I can't figure out what's wrong.
#include <iostream>
#include <cstdlib>
#include <memory>
using namespace std;
class invalidArg
{
|
by: Gas |
last post by:
I am new to C#, I want to perfoem a calculation and I have a weird out come
from the app.
Here is the code
double percentage = 0;
percentage = ctrl1.Height / (ctrl1.Height+ ctrl2.Height)
...
|
by: nick |
last post by:
I'm having a really weird problem. Take a look at this screenshot.
http://users.aber.ac.uk/njb4/dotnetproblem1.jpg
Notice the 4 watches at the bottom, _totalRecords, MyDataGrid.PageSize
and...
|
by: baong |
last post by:
dear all
i have use this line to time in many my web base appl.
but now i found a weird problem
the javascript line is the same
but i use the calculation 2 time
@ the first time, it is ok, 3 *...
|
by: JJ |
last post by:
Dear all,
I have this weird problem on the website I maintain....
A few visitors seemed to be unable to XS the website. It has a front image,
with a link underneeth it saying: click here to...
|
by: Todd |
last post by:
OK...I have a form that has two text boxes. These two fields are being
filled from a file import, which works fine. I am then passing these
values into a custom class with both values typed as...
|
by: DavidM |
last post by:
Hi all,
I'm embedding python in a C prog which is built as a linux shared lib.
The prog is linked against libpython, and on startup, it calls
Py_Initialize().
The prog imports a pure-python...
|
by: ssecorp |
last post by:
I was looking into currying and
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) on win32
Type "copyright", "credits" or "license()" for more information.
...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |