Discussion:
Operator Problem
(too old to reply)
JaseyM
2008-06-12 10:09:00 UTC
Permalink
I have tried to use the \ operator to get a whole number from a decimal
number. This does not work as intended, and rounds up to the next whole
number. e.g 16.75 \ 1 returns 17 where 16 is expected. I have tried 9 \ 2
which returns 4 correctly therefore I can only assume this is a bug with \ 1.
I have worked around this issue by using 16.75 - (16.75 MOD 1) but felt I
needed to report this so others are not caught out with this. I use vb.net
2005.
Dean Earley
2008-06-12 10:31:57 UTC
Permalink
Post by JaseyM
I have tried to use the \ operator to get a whole number from a decimal
number. This does not work as intended, and rounds up to the next whole
number. e.g 16.75 \ 1 returns 17 where 16 is expected. I have tried 9 \ 2
which returns 4 correctly therefore I can only assume this is a bug with \ 1.
From the help file, \ just converts all numbers to integers first
(using bankers rounding which rounds up for your samples), the result is
then truncated
Post by JaseyM
I have worked around this issue by using 16.75 - (16.75 MOD 1) but felt I
needed to report this so others are not caught out with this. I use vb.net
2005.
16.75 - (16.75 MOD 1) gives 0...

Why not just use Int()?

Please note that you have asked in a VB classic group so things may be
slightly different for .NET.
--
Dean Earley (***@icode.co.uk)
i-Catcher Development Team

iCode Systems
Jan Hyde (VB MVP)
2008-06-12 10:36:56 UTC
Permalink
JaseyM <***@discussions.microsoft.com>'s wild thoughts
were released on Thu, 12 Jun 2008 03:09:00 -0700 bearing the
Post by JaseyM
I have tried to use the \ operator to get a whole number from a decimal
number. This does not work as intended, and rounds up to the next whole
number. e.g 16.75 \ 1 returns 17 where 16 is expected. I have tried 9 \ 2
which returns 4 correctly therefore I can only assume this is a bug with \ 1.
I have worked around this issue by using 16.75 - (16.75 MOD 1) but felt I
needed to report this so others are not caught out with this. I use vb.net
2005.
Then your in the wrong group, this is a VB6 group.

--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
JaseyM
2008-06-13 22:01:00 UTC
Permalink
I am in a Visual Basic Bugs Group, nowhere does it say vb6?!?!?

Let me know if there is a vb.net 2005 group to post to.
Post by Jan Hyde (VB MVP)
were released on Thu, 12 Jun 2008 03:09:00 -0700 bearing the
Post by JaseyM
I have tried to use the \ operator to get a whole number from a decimal
number. This does not work as intended, and rounds up to the next whole
number. e.g 16.75 \ 1 returns 17 where 16 is expected. I have tried 9 \ 2
which returns 4 correctly therefore I can only assume this is a bug with \ 1.
I have worked around this issue by using 16.75 - (16.75 MOD 1) but felt I
needed to report this so others are not caught out with this. I use vb.net
2005.
Then your in the wrong group, this is a VB6 group.
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
Bob O`Bob
2008-06-14 01:11:24 UTC
Permalink
Post by JaseyM
I am in a Visual Basic Bugs Group, nowhere does it say vb6?!?!?
Nowhere does it say "dotnet" either.

It is not our fault Microsoft broke compatibility.
Post by JaseyM
Let me know if there is a vb.net 2005 group to post to.
I have little reason to care what's over there, I don't use it.
Here's a whole list for you to seek one yourself:


microsoft.public.dotnet.academic
microsoft.public.dotnet.academic.assignment_manager
microsoft.public.dotnet.datatools
microsoft.public.dotnet.distributed_apps
microsoft.public.dotnet.faqs
microsoft.public.dotnet.framework
microsoft.public.dotnet.framework.adonet
microsoft.public.dotnet.framework.aspnet
microsoft.public.dotnet.framework.aspnet.announcements
microsoft.public.dotnet.framework.aspnet.buildingcontrols
microsoft.public.dotnet.framework.aspnet.caching
microsoft.public.dotnet.framework.aspnet.datagridcontrol
microsoft.public.dotnet.framework.aspnet.mobile
microsoft.public.dotnet.framework.aspnet.security
microsoft.public.dotnet.framework.aspnet.webcontrols
microsoft.public.dotnet.framework.aspnet.webservices
microsoft.public.dotnet.framework.clr
microsoft.public.dotnet.framework.compactframework
microsoft.public.dotnet.framework.component_services
microsoft.public.dotnet.framework.drawing
microsoft.public.dotnet.framework.interop
microsoft.public.dotnet.framework.microframework
microsoft.public.dotnet.framework.odbcnet
microsoft.public.dotnet.framework.performance
microsoft.public.dotnet.framework.remoting
microsoft.public.dotnet.framework.sdk
microsoft.public.dotnet.framework.setup
microsoft.public.dotnet.framework.webservices
microsoft.public.dotnet.framework.webservices.enhancements
microsoft.public.dotnet.framework.windowsforms
microsoft.public.dotnet.framework.windowsforms.controls
microsoft.public.dotnet.framework.windowsforms.databinding
microsoft.public.dotnet.framework.windowsforms.designtime
microsoft.public.dotnet.framework.wmi
microsoft.public.dotnet.general
microsoft.public.dotnet.internationalization
microsoft.public.dotnet.languages.csharp
microsoft.public.dotnet.languages.jscript
microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.controls
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.languages.vb.upgrade
microsoft.public.dotnet.languages.vc
microsoft.public.dotnet.languages.vc.libraries
microsoft.public.dotnet.myservices
microsoft.public.dotnet.scripting
microsoft.public.dotnet.security
microsoft.public.dotnet.vjsharp
microsoft.public.dotnet.vsa
microsoft.public.dotnet.xml
microsoft.public.msdn.drgui.drguidotnet.discussion
microsoft.public.vsnet.act
microsoft.public.vsnet.debugging
microsoft.public.vsnet.documentation
microsoft.public.vsnet.enterprise.tools
microsoft.public.vsnet.general
microsoft.public.vsnet.ide
microsoft.public.vsnet.jlca
microsoft.public.vsnet.servicepacks
microsoft.public.vsnet.setup
microsoft.public.vsnet.vsip
microsoft.public.vsnet.vss
microsoft.public.vsnet.vstools.office

--
Jan Hyde (VB MVP)
2008-06-16 08:03:39 UTC
Permalink
JaseyM <***@discussions.microsoft.com>'s wild thoughts
were released on Fri, 13 Jun 2008 15:01:00 -0700 bearing the
Post by JaseyM
I am in a Visual Basic Bugs Group, nowhere does it say vb6?!?!?
So shout at Microsoft, they chose to name a completely
different progamming language VB when they already have a
language called VB.
Post by JaseyM
Let me know if there is a vb.net 2005 group to post to.
Look for groups with 'dotnet' in them

J
Post by JaseyM
Post by Jan Hyde (VB MVP)
were released on Thu, 12 Jun 2008 03:09:00 -0700 bearing the
Post by JaseyM
I have tried to use the \ operator to get a whole number from a decimal
number. This does not work as intended, and rounds up to the next whole
number. e.g 16.75 \ 1 returns 17 where 16 is expected. I have tried 9 \ 2
which returns 4 correctly therefore I can only assume this is a bug with \ 1.
I have worked around this issue by using 16.75 - (16.75 MOD 1) but felt I
needed to report this so others are not caught out with this. I use vb.net
2005.
Then your in the wrong group, this is a VB6 group.
--
Jan Hyde
https://mvp.support.microsoft.com/profile/Jan.Hyde
--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde

Continue reading on narkive:
Loading...