VB format number

VB (.NET) provides FormatNumber function that can be used to format numbers. The general form of the format number is FormatNumber(Exp_num[, NumDigitsAfterDecimalPlace[,LeadingZero[,UseParforNegative[,UseSeparator]]]]).
-Exp_num: it is the number to be formatted.
-NumDigitsAfterDecimalPlace (optional): it is the number of digits to display after decimal point.
-LeandingZero (optional): This argument takes TriState.True or TriState.False value. If you specify TriState.True, the 0 digit is placed before decimal point to the number that is between 0.00 and and 1.00.
-UseParforNegative (optional): This argument takes TriState.True or TriState.False value. If it takes TriState.True, the negative number is place between parentheses.
-UseSeparator (option): This argument takes TriState.True or TriState.False value. If you want to display thousand separator (,) , use TriState.True.


   Sub Main()
     Dim value As Double = -83992.97752
     Dim val = FormatNumber(value, 3, TriState.True, TriState.True, TriState.True)
     Console.WriteLine(val )
     Console.ReadLine()
   End Sub

Posted by: Dara | post date: 02-10-2013 | Subject: VB.NET Programming Language




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.