Welcome :Guest

 Sign In Register
Win Surprise Gifts!!!
Congratulations!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

 Home >> Articles >> General >> Post New Resource

# Numeric and Date Functions in VB.NET

Posted By:Abhisek Panda       Posted Date: November 14, 2009    Points: 25    Category: General    URL: http://www.dotnetspark.com

# Numeric Functions in VB.NET:-

All the numeric functions in VB.NET are implemented as methods of the Math Class. To use any of the Math methods provided by VB.NET, you must prefix the methods with "Math.". Some of these functions and there uses are given below,

Abs(int):- This method returns the absolute valu of the specified number
`Dim MyNo As DoubleMyNo=Math.Abs(65.45)'returns 65.45MyNo=Math.Abs(-65.45)'returns 65.45`

Min(int,int):- This function returns the smaller of two numbers specified.
`Dim MyNo As DoubleMyNo=Math.Min(65.45,45)'returns 45`

Max(int,int):- This function returns the larger of two numbers specified.
`Dim MyNo As DoubleMyNo=Math.Max(65.45,45)'returns 65.45`

Round(int):- It returns the rounded value of the specified number.
`Dim MyNo As DoubleMyNo=Math.Round(65.45)'returns 65`

Pow(int,int):- This function returns a specified number raised to the specified power. If it tales two arguments a, b then it will return a^b.
`Dim MyNo As DoubleMyNo=Math.Pow(2,3)'returns 2^3, i.e, 8`

Sqrt(int):- This function returns the square root of the specified number.
`Dim MyNo As DoubleMyNo=Math.Sqrt(4)'returns 2MyNo=Math.Sqrt(36)'returns 6`

## Date Functions:-

In VB.NET there are also some date function such as,

Now():- This function returns a date value containing the current date and time according to your system setting.
`Dim Dt As DateDt=Now()'returns "11/05/2009 7:30:59AM"`

Today():- This function returns a date value containing the current date only.
`Dim Dt As DateDt=Today()'returns "11/05/2009" `

TimeOfDay():- It will return a date value containing only current time.
`Dim Dt As DateDt=TimeOfDay()'returns "2:26:34"`

There is also several other functions relating to date and time and also math functions. I have included only the frequently used functions.

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
 Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here