my Q is like this,
i want to design a calculation which use the number user enter to "/" by 100.
so , offcouse the result mayb in double or integer.
after that my calculation just wanna user the "whole number" of the result to calculate other things. can anyone help me? thks.
For eg: 9 / 2 = 4.5
and i just wanna take the number "4" to calculate other calculation.
so, how to call it out?
6 2505
i want to design a calculation which use the number user enter to "/" by 100.
so , offcouse the result mayb in double or integer.
after that my calculation just wanna user the "whole number" of the result to calculate other things. can anyone help me? thks.
For eg: 9 / 2 = 4.5
and i just wanna take the number "4" to calculate other calculation.
so, how to call it out?
You want the Int() function. For example, if you said Result = Int(9 / 2) you would end up with 4 in Result. You can get a similar effect by simply placing the value in a "whole number" type variable (Byte, Integer, Long etc.) except that then it will be rounded to the nearest whole number, not just "chopped". In other words, if you defined variable Result as an Integer and said Result = 9 / 2 you would get 5 in Result.
so , if the result is 4.99, but i oso want to use the "4" only .so what should i do?
oso use int() ?
my Q is like this,
i want to design a calculation which use the number user enter to "/" by 100.
so , offcouse the result mayb in double or integer.
after that my calculation just wanna user the "whole number" of the result to calculate other things. can anyone help me? thks.
For eg: 9 / 2 = 4.5
and i just wanna take the number "4" to calculate other calculation.
so, how to call it out?
Yha its simple,
Result = 9 \ 2
then u get 4
Result = 9 \ 2
then u get 4
Like I said, assigning it to an Integer or Long variable will round up or down to the nearest whole number, while Int() function will always round down.
I've done a bit more checking. Unfortunately, it looks as though VB actually has the rounding rules slightly wrong. 4.5 should round up to 5, but doesn't. But if for example you place 4.51 in your variable, then it will round up to 5.
kadghar 1,295
Recognized Expert Top Contributor
Int() gives you back the lower integer, Fix() will give you the closest to zero..
i.e:
Int (4.99) = 4
Int ( - 3.2) = -4 (see, is the one below)
and
fix (4.99) = 4
fix( - 3.2) = -3 (i've found this one more useful)
And if you want a rounded result, use round and the number of decimals, use zero decimals to round to the closest integer.
Thanks for the extra details, kadghar. Good head-up about the "nearer to zero" thing. I always forget about the effect of negative values.
However, using Round with 0 digits seems a bit superfluous, since it produces the same result as simply placing the value into an integer field. I suppose it depends on the circumstances whether it would be worth using or not.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mensan |
last post by:
I am trying to compute the differnece between two dwords in visual basic and
keep getting the wrong value being computed. I have the following structure
defind:
Public Type HighLowQuote
TradeDate As String
OpenPrice As Double
HighPrice As Double
LowPrice As Double
ClosePrice As Double
|
by: Boštjan Jerko |
last post by:
Hello!
I have a list of lists (e.g. ,,]) and
would like to do index on the first element of the lists.
Can it be done?
B.
|
by: John Baker |
last post by:
Hi:
I know this is a strange question, but I have inherited a system where files are copied
and records re auto numbered (as an index field) )frequently, and I am wondering how high
the number can go without the system crashing.
An ancillary question is how one resets an auto number so that the sequence starts again
at 1.
In the case of this file, the auto number field serves no useful purpose except as an
|
by: Sooha Park Lee |
last post by:
I would like to compare two "double" numbers.
To overcome round-off error, I am using the following strategy:
rounding each number and try to convert it into interger by multiplying 10E6.
One example of number is 0.765543.
I do not want "ceil" or "floor".
Any idea will be welcome.
Can I find any smart code already existed on the web?
|
by: Assaf |
last post by:
Hi all,
My client is using an online service provider that processes survey
responses.
After a user fills survey.aspx and presses the OK button, 2 things need to
happen:
1. the data has to be posted behind the scenes to the provider's URL (e.g.,
http://www.surveyprocessingprovider.com/srvy1?field1=response1&field2=response2)
2. the user has to be redirected to thankyou.aspx.
| |
by: theyas |
last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE
I've asked about this before and didn't get a satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again.
The app I've written has three ASPX pages. One is a combined page which writes a little text...
|
by: Zero |
last post by:
Hi everybody,
i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.
For int the command could be:
printf("\n%20s\t%7u\t%13i\t%13i","signed int",sizeof(signed
int),INT_MIN,INT_MAX);
|
by: Franky |
last post by:
Can a Decimal variable be set to "Not a Number"
I've been looking in the help and can't find any reference to that.
Thanks in advance
|
by: hmznzr |
last post by:
when a user inputs a value into a text box, i am searching that value in my dataset. although the number that i entered is in my dataset, i am getting this excemption.
please help me
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |