Controlling decimal digits

Hi

I have a few numeric hours appear on a report like this;

       2
  9.75
  12.5

This is all fine but when a number like 1.83333 appears I only would like it 
to limit to two decimal places as 1.83. How can I achieve this?

Thanks

Regards



0
John
3/1/2010 6:48:35 AM
access 16762 articles. 3 followers. Follow

6 Replies
647 Views

Similar Articles

[PageSpeed] 21

On Mon, 1 Mar 2010 06:48:35 -0000, "John" <info@nospam.infovis.co.uk> wrote:

>Hi
>
>I have a few numeric hours appear on a report like this;
>
>       2
>  9.75
>  12.5
>
>This is all fine but when a number like 1.83333 appears I only would like it 
>to limit to two decimal places as 1.83. How can I achieve this?
>
>Thanks
>
>Regards
>

Set the Format to #.00; or use the Round() function if you're calculating the
value to round it to two decimals.
-- 

             John W. Vinson [MVP]
0
John
3/1/2010 7:06:19 AM
Hi John

Thanks. Using #.00 works for 1.83333 to make it 1.83 but for other numbers 
2, 9.75, 12.5 it also changes them to 2.00, 12.50. How can I get round that?

Basically the values are hours and it looks good if no zeros show after 
decimal if its a complete number.

Thanks

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message 
news:1qpmo5hjko1d5kljv2610vl75f2kr7jm5m@4ax.com...
> On Mon, 1 Mar 2010 06:48:35 -0000, "John" <info@nospam.infovis.co.uk> 
> wrote:
>
>>Hi
>>
>>I have a few numeric hours appear on a report like this;
>>
>>       2
>>  9.75
>>  12.5
>>
>>This is all fine but when a number like 1.83333 appears I only would like 
>>it
>>to limit to two decimal places as 1.83. How can I achieve this?
>>
>>Thanks
>>
>>Regards
>>
>
> Set the Format to #.00; or use the Round() function if you're calculating 
> the
> value to round it to two decimals.
> -- 
>
>             John W. Vinson [MVP] 


0
John
3/1/2010 7:13:27 AM
Basically I need formatting applied as below;

    Before   /  After
            2   /       2
       9.75   /  9.75
       12.5   /  12.5
 1.83333   /  1.83

Basically if digits after decimal are more than two then round/trim to two 
decimal., leave everything else alone.

Thanks

Regards

"John W. Vinson" <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in message 
news:1qpmo5hjko1d5kljv2610vl75f2kr7jm5m@4ax.com...
> On Mon, 1 Mar 2010 06:48:35 -0000, "John" <info@nospam.infovis.co.uk> 
> wrote:
>
>>Hi
>>
>>I have a few numeric hours appear on a report like this;
>>
>>       2
>>  9.75
>>  12.5
>>
>>This is all fine but when a number like 1.83333 appears I only would like 
>>it
>>to limit to two decimal places as 1.83. How can I achieve this?
>>
>>Thanks
>>
>>Regards
>>
>
> Set the Format to #.00; or use the Round() function if you're calculating 
> the
> value to round it to two decimals.
> -- 
>
>             John W. Vinson [MVP] 


0
John
3/1/2010 7:19:54 AM
On Mon, 1 Mar 2010 07:19:54 -0000, "John" <info@nospam.infovis.co.uk> wrote:

>Basically I need formatting applied as below;
>
>    Before   /  After
>            2   /       2
>       9.75   /  9.75
>       12.5   /  12.5
> 1.83333   /  1.83
>
>Basically if digits after decimal are more than two then round/trim to two 
>decimal., leave everything else alone.

If just using Round() doesn't work, then I don't know any *simple* way to do
that. You would need some VBA code to parse the number and construct a text
string with the desired decimals.
-- 

             John W. Vinson [MVP]
0
John
3/1/2010 5:10:21 PM
"John" <info@nospam.infovis.co.uk> wrote in message 
news:%23oTx1sQuKHA.5936@TK2MSFTNGP04.phx.gbl...
> Hi
>
> I have a few numeric hours appear on a report like this;
>
>       2
>  9.75
>  12.5
>
> This is all fine but when a number like 1.83333 appears I only would like 
> it to limit to two decimal places as 1.83. How can I achieve this?
>
> Thanks
>
> Regards
>
>
> 

0
De
3/13/2010 5:59:12 PM
p^




"John" <info@nospam.infovis.co.uk> a �crit dans le message de groupe de 
discussion : #oTx1sQuKHA.5936@TK2MSFTNGP04.phx.gbl...
> Hi
>
> I have a few numeric hours appear on a report like this;
>
>       2
>  9.75
>  12.5
>
> This is all fine but when a number like 1.83333 appears I only would like 
> it to limit to two decimal places as 1.83. How can I achieve this?
>
> Thanks
>
> Regards
>
>
> 
0
joelgeraldine
3/17/2010 1:34:12 PM
Reply:

Similar Artilces:

Improving Accuracy Of Decimal Calculations
I am writing an app in C# to keep details of expenditure in relation to a small block of flats. There are 9 flats and costs are apportioned based on the lease terms, in all about 12 different categories each with a different percentage cost for each flat. I store the amounts and the proportions as decimal numbers with 2 decimal places in an Access database. I am using one central function to do the calculations: public static Decimal CalculateProportion(Decimal amount, Decimal proportion) { double famount = (double)amount; double fproportion = (double)proportion; doub...

Using Self Certify Digital ID with Shared Files
You can use the MS Self Certification utility to create a Digital ID to share macro enabled files with other XL users, even those running at high security. Here's how: File Originator: 1. Run c:\program files\OfficeXP\Office10 \selfcert.exe (if file not found, use add/remove on MSOffice, it's in Office Tools) 2. Enter a name (eg John Doe, ACME Corp) 3. Open XL file you want to certify and open up VBE 4. Go Tools|Digital Signature 5. Click Choose 6. You should see the name of the cert that you just created on this list. Select it then click OK, then OK again 7. Save and Close fi...

decimal places
is there a way to allow more than 3 decimal places in invoices? ...

Excel Text Box Controls
Is there any way to allow a user of a spreadsheet to cut and paste text in and out of an Excel Text Box? Is there a setting that I am missing? Also, the workbook is protected from altering specific cells. Ron, when protecting the workbook, deselect the Objects check box under Protect worksheet for (Tools > Protection > Protect Sheet). That will allow users to cut/copy and paste into and out of text boxes. (I'm using Excel 2000, btw. YMMV.) -- DDM "DDM's Microsoft Office Tips and Tricks" Visit us at www.ddmcomputing.com "Ron Green" <rgreen@elibertyban...

hiding and showing controls
I have hidden several controls during design. Now, what I want to do is show them and then go through a loop that updates them say static label and a progress bar control. But when I try this, I get weird results. Sometimes it will show both before going into the loop and other times it will show only one control or none at all though it does sometimes show them both after the loop is finished. Any thoughts on how I can fix this problem. Roger Z.K. wrote: > I have hidden several controls during design. Now, what I want to do is > show them and then go through a loop that up...

Updating Controls from a Thread Causes Access Violation
Hi: I have a VC++ 6.0 Dialog based application where I'm trying to update a static control from a thread. My main dialog is: CMyDlg* myDlg; I create the thread with the following code: myDlg = this; void myThread(void *ch); _beginthread( myThread, 1000, (void*)(ch)); Then, I am updating my static control from within the thread with: myDlg->myVar = "Test"; myDlg->OnUpdateControls(); where myVar is a CString variable associated with my static control. The method OnUpdateControls is: void CMyDlg::OnUpdateControls() { UpdateData(FALSE); } The problem is that when ...

decimal alignment
Is there a way to have figures centered in a column under a heading and aligned on the decimal point? ...

CSpinButton, CEdit Buddy Decimal/Float Format
How can i do this darn thing. The easier the better. I mean, i set up the spin control an the CEdit to be buddies and all i am able to work with is integers. What i need is the ability to set up the buddy to be a Float, and to increment in some kind of fraction, say tenths or hundreths. thanks!!!! 1. While creating the control, dont use UDS_SETBUDDYINT style. 2. Write a handler for UDN_DELTAPOS m_edit is the member variable for buddy edit textbox. void CYourDialog::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult) { if (!UpdateData(TRUE)) return; NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; ...

color swatch control,
I have a button on a "main" dialog that launches another ChooseColor dialog. In the main dialog, I want to display a small box with the color that is currently selected. Does a control for this already exist (don't want to reinvent the wheel if I don't have to). Thanks for and advice. Look up the common dialog controls. CColorDialog -- - Mark Randall http://www.temporal-solutions.co.uk "We're Systems and Networks..." "It's our job to know..." "vsgdp" <hello@null.com> wrote in message news:OBEog.6$5K2.2@fed1read03... &g...

Allow use of a control scroll bar in protected worksheet
Hi all, I have a control Scroll Bar in my worksheet (Excel 2003). I want to protect everything except the use of that scroll bar (let the possibility to scroll). I've tried to play with all the options in the Protect Sheet dialog box.... but when I click my scroll bar it doesn't want ! Any clue would be very apreciated. Thanks ! Marco Do you have a linked cell assigned to that scrollbar? If you do then that cell can't be locked on a protected worksheet. You could either unlock it or assign a linked cell on a different worksheet. Marco wrote: > > Hi all, > I have...

digital signature
I have an excel sheet that resides on a network drive, which is supposed to run a macro when it starts up, however the users security settings stop it from running. So I decided to try and get a digital certificate from CACert, a free certificate place. I have created a client certificate from CACert, and added it to my personal certificates, but when I got to sign the excel vba project my newly added certificate does not show up in the list. If anyone has any idea why this CACert is not working, or how to attach it to my excel project, or perhaps a better way to achieve the same result it wo...

Controls within an MDI view
Hi, I've seen a few threads on this, all of them several years old now. And I've tried what I saw in those threads with no luck. All I want to do is add a few controls inside my MDI doc/view windows. So, in my xxxview.h file, I have: public: CButton bbb; And in my xxxview.cpp file, I have: int CxxxView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; bbb.Create("hello", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(50, 50, 200, 100), this, 555); return 0; } It builds fine, but I do...

Check Digit in Modulo 10
I am trying to edit UPC codes, in MS Excel, that were provided to me by a supplier without the check digit. Does anyone know how I can use Excel to calculate the check digit? akpetshop, Try this.. http://www.export911.com/e911/coding/upcChar.htm CP.Dinesh Jumbo Electronics Co.LLC www.jumbocorp.com "akpetshop" wrote: > I am trying to edit UPC codes, in MS Excel, that were provided to me by a > supplier without the check digit. Does anyone know how I can use Excel to > calculate the check digit? Here is a very srtong Addin that will do what you need to do plus more...

Dropdown button in a toolbar control
Hi all, I'm trying to implement the dropdown button in a toolbar control. I try to handle the TBN_DROPDOWN message with the ON_NOTIFY macro: ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnToolbarDropDown) afx_msg void OnToolbarDropDown(NMTOOLBAR* pnmtb, LRESULT *plr); and get the following error: error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(NMTOOLBARA *,LRESULT *)' to 'void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)' Does anyone know how to fix it? Cheers Kozlo Here's something to try... Change the function to be...

ActiveX control and MFC
Hi, I am creating an activex control(say it as OCX1) by using MFC ActiveX ControlWizard. Also I used(inserted) another custom ActiveX control(say it as OCX2) inside OCX1. My question is: How can I add OCX2's events handler into OCX1 since I couldn't find events functions in OCX2's wrapper class or Message maps of ClassWizard to add ? I appretiate any help. ...

List Control Header Notification are missing!!!
Hello, I know that this issue has been discussed allready several times before, but I didn't find a working solution for me. I can not get any notification from my CListCtrl Header control. There were talking about ON_NOTIFY_REFLECT instead of ON_NOTIFY, but I have ON_NOTIFY as needed. Also, I derived a ListCtrl from CListCtrl and tried to get the notifications there, but I didn't. I try to recieve the dblclick or itemchange messages. Thanks in advance~! <dushkin@012.net.il> wrote in message news:faecfce7.0401050144.43bf8e2e@posting.google.com... > Hello, > I know tha...

How To Enable Active X Controls???
I have IE8 on Windows XP Home Edition with XP3 and I cannot activate Active X controls. Have tried 2 or 3 suggestions, going into Internet Options and made changes, but still cannot sign in to some web sites as they say I need to activate Active X controls! Any ideas for fixing this problem would be appreciated. Thanks. What anti-virus application or security suite is installed and is your subscription current? What anti-spyware applications (other than Defender)? What third-party firewall (if any)? Were any of these applications running in the background when you instal...

How do I use .Create on a control class?
For example, I want to progamatically add a CEdit to the main dialog in a dilaog based app. So, I declare a CEdit object called skill, then I call skill.Create(<style flags>, <rect>, <CWnd*>, etc... The question is this, where do I get the CWnd* ? I can declare one, but what do I initialize it to? I have tried using "this" as my CWnd* but if I do that, the control does not show up in the dialog. I did specify WS_CHILD and WS_VISIBLE in my style flags. What am I doing wrong? CWnd* is the base class of CDialog*, just pass it 'this' (self reference ...

Client Validation in a custom control
I am creating a custom control that has a custom validator in it. I want to do client side validation as well. This control is going to be called on a page inside a repeater so there will be more than one instance of this control on the page. Won't this cause a problem with the javascript since the control will render the javascript more than once on the page and therefore have several functions with the same name? Is there a way around this? I apologize for this rudimentary question - I really don't have a lot of experience working with custom controls. ...

Hide/Show controls based on value of radio button
I need to hide/show some controls on a form based on the value of a radio button. This is what I have so far and it doesn't seem to be working correctly. My two buttons have a value of 1 and 2 respectively. Private Sub Frame4_Click() Select Case Frame4.Value Case 1 Me.Combo15.Visible = False Me.cmdUpdateRole.Enabled = False Me.cmdEditUser.Visible = False Call ShowEditControls 'we will need the same controls as our edit form Me.txtUsername.Visible = True Call clearForm 'just in case End Sele...

Decimal points- rounding up to the nearest cent
We are a small business selling parts with special pricing- for instance, a box of bolts could sell for $1.49/1000. This is fine until we need to charge a customer for individual units of the above and the customer's receipt shows an amount not rounded up or down to the nearest cent but exact pricing per unit. Is there a way to operate the pos so that in similar situations prices are rounded to the nearest cent? -- Ma Bell HI, The only limit of decimals are allowed currently is 3 but I can see that in your case it is more than 3 please check with partner he must help you out in ...

Problems purchasing Money Plus thru Digital River
I am at my witzend with Digital River. I am trying to purchase Money Plus thru the Microsoft website to get the rebate. I enter all of my information and get a page that says "unable to process order, check your information and try again". I have contacted "Microsoft" (disguise for Digital River) and am told that the "accounting dept" has if fix it and to try back in 24 hrs. This has been going on since 10/10/2007. I've tried escalating to a supervisor who tells me the same thing. Today a supervisor was able to get the order cleared and told me to try aga...

How to avoid a control covering another one?
hi,all For example, in vc++, I have two Labels, Label1 and Label2. I will move Label2 from window's top to window's bottom. When Label2 passes Label1, it is covered by Label1 and can be seen. So how to make sure Label2 is on the top of Lable1 when they are together? SetWindowPos so the Z-order of label2 is correct with respect to label1. Note that this might have other effects on your code, e.g., the Z-order of labels with shortcuts is to set the focus on the next active control, so you may have to reset it after you move it to make sure it is back to the correct relationship with oth...

working with a tab control with no tabs in design view
I'm using a tab control in Access 2000, and the user requested to have buttons in the form header, instead of the built-in tabs (so that when they scroll down, they can still switch tabs). Now, this works fine. However, when I'm in Design View, I can't access the tabs without changing the tab control's Style back to Tabs. But I want to be able to place controls in that space at the top where the tabs used to be. But if I need to turn the tabs back on when I need to make design changes, then I can't do that. So the result is wasted space at the top of the tab control,...

Problem with unbased controls
Hello, I have a client who is still using an Access 97 DB application and it has been giving me the fits recently. They are thinking about upgrading to 2003, but it will take some time. It is a very old application originally written in Access 2 (by someone else), so it has tons of macro's I have made some updates and tested them on my machines, where everything works correctly. At my client's office however there is a problem, mostly with a report. In the report's Detail Format event proc several controls are populated with mailing and billing info by copying data from hid...