Results 1 to 4 of 4

Thread: Formating

  1. #1
    Join Date
    Jul 2006
    Posts
    26

    Unanswered: Formating

    I am currently puting finishing touches to a Tax Computin Software. But I am worried about the number of decimal place the program displays - Four decimal place. And some of the fields display only one decimal place while some do not at all!

    The program has Basic Salary, Housing Allowance ..., Gross Pay , Reliefs, Taxable Pay, Annual Tax payable, and Monthly Tax Payable fields. I declared all the variables As Currency.

    I want the program to display only two decimal place. From the Visual Basic 6 books I use, it is clear that Currency Data type estimates to four decimal place.

    Please what do I do to make the program display only two decimal place?

    Below is part of my codes:
    If Val(txtTaxablePay.Text) <= 30000 Then
    a = Val(txtTaxablePay.Text) * 0.05
    txtAnnualTaxPayable.Text = a
    ElseIf Val(txtTaxablePay.Text) <= 60000 Then
    b = Val(txtTaxablePay.Text) - 30000
    a = 30000 * 0.05
    c = b * 0.1
    txtAnnualTaxPayable.Text = a + c
    ElseIf Val(txtTaxablePay.Text) <= 110000 Then
    b = Val(txtTaxablePay.Text) - 60000
    a = 30000 * 0.05
    c = 30000 * 0.1
    d = b * 0.15
    txtAnnualTaxPayable.Text = a + c + d
    ElseIf Val(txtTaxablePay.Text) <= 160000 Then
    b = Val(txtTaxablePay.Text) - 110000
    a = 30000 * 0.05
    c = 30000 * 0.1
    d = 50000 * 0.15
    e = b * 0.2
    txtAnnualTaxPayable.Text = a + c + d + e
    ElseIf Val(txtTaxablePay.Text) > 160000 Then
    b = Val(txtTaxablePay.Text) - 160000
    a = 30000 * 0.05
    c = 30000 * 0.1
    d = 50000 * 0.15
    e = 50000 * 0.2
    f = b * 0.25
    txtAnnualTaxPayable.Text = a + c + d + e + f

    End If
    curMonthlyTaxPayable = Val(txtMonthlyTaxPayable.Text)

    txtMonthlyTaxPayable.Text = Format(curMonthlycurTaxPayable, "Currency")


    Thank you.

    Akinyemi

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I haven't done straight VB since I took the college classs, but...

    You can set the decimal places property of the text box, it should
    be something like

    txtMonthlyTaxPayable.DecimalPlaces = 2
    Inspiration Through Fermentation

  3. #3
    Join Date
    Dec 2006
    Posts
    3
    You can round the value using RND function

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    That will round 16.0025 to 16, and display 16, not 16.00
    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •