Numbers





Below Is a list of standard numeric format specifiers
You can add or subtract time durations using the normal operators.




Dividing Double with Integer
If you have a double datatype containing 1234567

dbValue = 1234567 
dbValue.ToString("#,#") = 1,234,567



Adding Leading Zeros

dbValue = 25 
sValue = dbValue.ToString.PadLeft(4,"0"c)
Do While (dbValue <= 200)
   dbValue = dbValue + 50
   sValue = dbValue.ToString.PadLeft(4,"0"c)
Loop



Random Numbers

.NET has a Random class
The Next function has a parameter that allows you to specify a range of integers you want returned.
Passing in 10 returns numbers from 0 to 9.

Dim objRandom As Random = New Random 
Dim iRand As Integer = objRandom.Next(10)



NumberFormatInfo


objNumberFormatInfo = New System.Globalization.NumberFormatInfo 
objNumberFormatInfo.NumberDecimalSeparator = "."


Converting Scientifc/Floating into double

dbValue = System.Double.Parse("4.5E8",Globalization.NumberStyles.Float, objNumberFormatInfo) 






© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Next