473,321 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Drop decimals and zeros when not needed

32
I'm trying to hide decimals and zeros when they're not needed. For instance, if I type 3 I'd like to show as 3 instead of 3.00, and if I type 3.5 I'd like it to show 3.5 instead of 3.50. I can't find how to do this but surely it can be done.
Thanks.
Sep 29 '07 #1
3 3591
missinglinq
3,532 Expert 2GB
We'll need a bit more information in order to help you, such as the datatype/format, etc. of the data you're talking about, as well as if the data is only being manually entered or if it's the results of calculations.

Linq ;)>
Sep 29 '07 #2
ADezii
8,834 Expert 8TB
I'm trying to hide decimals and zeros when they're not needed. For instance, if I type 3 I'd like to show as 3 instead of 3.00, and if I type 3.5 I'd like it to show 3.5 instead of 3.50. I can't find how to do this but surely it can be done.
Thanks.
missinglinq is correct in that we need more information, but if you need to format the results of numeric calculations to,
  1. A specific number of decimal places.
  2. Include/not include leading zeros for fractional values.
  3. Show/not show parenthesis for negative values.
  4. Use/not use a group delimiter for the calculation as specified in Regional settings.
the easiest approach is to use the FormatNumber() Function, as in:
Expand|Select|Wrap|Line Numbers
  1. FormatNumber(6/2, 0, vbFalse, vbTrue, vbTrue)
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. 3
NOTE: Refer to the Help files for detailed information on this Function. Arguments 0,vbFalse,vbTrue, vbTrue coincide with items 1 through 4. The 1st Argument is simply the expression itself (6/2).
Sep 29 '07 #3
NeoPa
32,556 Expert Mod 16PB
Controls (on Forms & Reports) generally have formatting settings. If you set the Format property to "General Number" and the Decimal Places property to "Auto", then you should get the layout you want. I looked at Textboxes for this but check the properties for other controls if you need.

If your requirement is to convert a number to text in this format than simply use the Val() function.

As the others have said, your question doesn't explain very clearly what you want so we're struggling to find the answer for you. Please remember that clearly asked questions can really save our time and effort and will also generally net you a lot more help (they're like gold dust and we all love to answer that type).

Lastly, please let us know how you get on with these answers and if you still need further help then make that clear too.

Good luck.
Sep 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: r.magdeburg | last post by:
//please tell me why... //and give me a hint to solve the problem with leading zeros. //snippet #include <iostream.h> #include <conio.h> int main() { int zahl = 0; cout << "Give me an int...
1
by: mmmgood1 | last post by:
Help, I'm linking an excel spreadsheet in access and I have datafields with leading zeros (01021). When the file is linked in access, I get a #num in the field with the leading zeros. The zeros...
2
by: RC | last post by:
I am getting input from a digital scale and if the weight on the scale is 9.25 pounds, the input looks like: 009.25LB I need to remove the LB and the leading zeros and have the remaining value...
16
by: s.seitz | last post by:
hi gods and programmers! i've got a weird problem with strlen() in C. in a current project, i need to AES_decrypt() some string. By now, i'm using the libssl (openssl) API. To get this...
6
by: Donal McWeeney | last post by:
Hi, Is there a way to specify on the predefined format strings like P and N that you want displayed all the decimals in the number... for example 3 will display 3 2.1 will display 2.1...
3
by: Chua Wen Ching | last post by:
I have a problem. But on .NET 1.1 My Scenario: Actually I will have a string of hexadecimals read from a xml file. Then from the hexadecimals, i will add 1 value whenever i made any...
9
by: Chester | last post by:
I'm working on an app that records data collected by service technicians (VB.Net front-end, SQL Server 2000 back end). The technicians need to record numbers with varying scale and precision. For...
38
by: ssecorp | last post by:
char* reverse(char* str) { int length = strlen(str); char* acc; int i; for (i=0; i<=length-1; i++){ acc = str; } return acc; }
8
by: =?Utf-8?B?a2FyaW0=?= | last post by:
Hello All, why is this code is not showing the result in this format: 0.00 and showing it as only 0 Private Sub btn1_Click Debug.Print(Format$(Rnd() * 100, "0.00")) Dim d As Double =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.