Author Topic: How to Decrease decimal digit  (Read 879 times)

Padex

  • Newbie
  • *
  • Posts: 11
    • View Profile
How to Decrease decimal digit
« on: January 24, 2017, 01:09:46 AM »
Hi All,

Based on code below, the calculation will give result display such 1.23456789000%. How to convert the decrease decimal become 1.23% only.

Please help... Thanks guys.

Code: [Select]
Private Sub RejectPercentage_ValueChanged(sender As Object, e As EventArgs) Handles RejectPercentage.TextChanged, TotalLabel.TextChanged, TextBox1.TextChanged
        Try
            RejectPercentage.Text = (CInt(TotalLabel.Text) / CInt(TextBox1.Text)) * 100
        Catch ex As Exception
        End Try
    End Sub

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5276
    • View Profile
    • AdvancedHMI
Re: How to Decrease decimal digit
« Reply #1 on: January 24, 2017, 06:38:41 AM »
 RejectPercentage.Text = ((CInt(TotalLabel.Text) / CInt(TextBox1.Text)) * 100).ToString("0.00")