Hello,
I need to know whether the result of a division is a integer or not.
dim x =60
dim y = 3
if x/y is a integer then
....
else
....
end if
How can i know that?
Thanks
André 5 15620
If x/y = x\y then
'Is an integer
else
'is not
end if
André wrote:
Hello,
I need to know whether the result of a division is a integer or not.
dim x =60
dim y = 3
if x/y is a integer then
....
else
....
end if
How can i know that?
Thanks
André
Thanks
"Theo Verweij" <tv******@xs4al l.nlschreef in bericht
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
If x/y = x\y then
'Is an integer
else
'is not
end if
André wrote:
Hello,
I need to know whether the result of a division is a integer or not.
dim x =60
dim y = 3
if x/y is a integer then
....
else
....
end if
How can i know that?
Thanks
André
"André" <sv*@sdv.sdwrot e in message
news:ea******** ******@TK2MSFTN GP02.phx.gbl...
Thanks
"Theo Verweij" <tv******@xs4al l.nlschreef in bericht
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
If x/y = x\y then
'Is an integer
else
'is not
end if
André wrote:
>Hello,
I need to know whether the result of a division is a integer or not. dim x =60 dim y = 3
if x/y is a integer then .... else .... end if
How can i know that? Thanks André
I would actually use Mod (modulus) to determine if a division result
(remainder) is 0.
Example:
Dim x As Integer = 12
Dim y As Integer = 6
Dim isInt As Boolean = x Mod y = 0
Console.WriteLi ne( _
"Remainder of {0} / {1} = {2} : Integral = {3}", _
x.ToString(), _
y.ToString(), _
(x / y).ToString(), _
(x Mod y = 0).ToString() _
)
The last parameter (x Mod y = 0) is the part that I would use :) So:
If x Mod y = 0 Then
' x / y results in a 0 remainder, meaning an int result (given that the
result falls within the scope of an integer and not a long.
Else
' x / y results in a non-0 remainder, meaning a floating point result.
End If
HTH :)
Mythran
"André" <sv*@sdv.sdschr ieb:
I need to know whether the result of a division is a integer or not.
dim x =60
dim y = 3
if x/y is a integer then
...
else
...
end if
'If Int(x) = x Then...'
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Andre,
Put option strict on in top of your program, than it will divide only
doubles using the non integer divide.
Cor
"André" <sv*@sdv.sdschr eef in bericht
news:Ou******** ********@TK2MSF TNGP03.phx.gbl. ..
Hello,
I need to know whether the result of a division is a integer or not.
dim x =60
dim y = 3
if x/y is a integer then
...
else
...
end if
How can i know that?
Thanks
André This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
If I need to check if a certain value does exist in a field, and return
either "yes" or "not" which query would be the most effestive?
|
by: Neil |
last post by:
I have a check box on a form that's bound to a function that returns a
True/False value. When the user clicks on the check box, I run some code
through the MouseDown event. Everything works fine.
Only problem is: when the user clicks on it, there's a beep, and then they
get a status bar message: "Control can't be
edited; it's bound to the expression...." That's very annoying and
disconcerting.
Is there a way to trap the click and...
|
by: Reddy |
last post by:
Hi,
How to check whether a given number is an integer
Thanks,
Reddy
|
by: Jan |
last post by:
Hi,
Is there any elegant way in VB.NET to check whether a certain string is part
of a "collection" of strings.
Something like IF "teststring" in {"string1", "string2", "string3",
"teststring"} THEN
Thanks,
Jan
|
by: Craig G |
last post by:
i have a small routine which i used in VB6 to check whether or not a field is off numeric input
but im having a problem when trying to change this over to .NET
what do i use instead of KeyAscii = 0 at the end of the routine? or how can i modify it to work in .NET??
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
IsNumericInput(TextBox1, 2,...
| |
by: Eli |
last post by:
Hi,
I want to check whether a value is a scalar. A scalar can be:
- None (null)
- string
- number (integer, float)
- boolean
How can I validate a value is one of these types?
I care about the value only, and not its class methods.
|
by: tommaso.gastaldi |
last post by:
Hi,
does anybody know a speedy analog of IsNumeric() to check for
strings/chars. I would like to check if an Object can be treated as a
string before using a Cstr(), clearly avoiding the time and resource
consuming Try... Catch, which in iterative processing is totally
unacceptable.
-tom
|
by: NEMA |
last post by:
How can i check the String letters?
i have a textbox and will filled with numbers.
i want to check if the number contain a '0' in font of the numbers,
e.g. '090',i would like to cut the 1st '0', that will change to '90'.
and i want to check whether it has a space there and return an error
message. e.g. '0 9 0', then it will return an error.
i really dont know how to do it? please give me some guidliance,
thanks.
|
by: user |
last post by:
Hi,
Let's say I have 2 dates in the b/m format:
Date 1 and date 2
How do I check whether Date2 is later than Date 1?
Date1. 21-Nov-2006 09:00:00 PM
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |