0

Im using this code for formatting my textbox.

Public Function TextFormat(ByVal sString As String) As String Dim num1 As Decimal Try num1 = Convert.ToDecimal(sString) TextFormat = FormatNumber(num1, 2) Return TextFormat Catch TextFormat = sString End Try End Function 

-the problem is its rounding off the number i input .. sample

textbox.text = "5999.99" it displaying "6000.00" how can i disable the auto rounding off number . or is there any other code for formatting text? "###,###,###.##" << it should be like this

thanks

2 Answers 2

2

use ToString Instead FormatNumber.

Public Function TextFormat(ByVal sString As String) As String Dim num1 As Decimal If Double.TryParse(sString, num1) Then Return num1.ToString("G") ' or ToString("F2") or ToString("0.00") Else Return sString End If End Function 
Sign up to request clarification or add additional context in comments.

Comments

0

Try to use:

 Dim number = Math.Truncate(CInt(textbox.text) * 1000) / 1000; textbox.text = number.toString 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.