.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Percentage Validation and Calculation in VB.net

Posted By:Narayanan       Posted Date: April 11, 2013    Points: 40    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Today we will discuss about Percentage Validation and Calculation using VB.net

  Code is below:

 Dim RegExpression As Regex
        Dim RegExpression1 As Regex
        RegExpression = New Regex("^((100.00)|([1-9][0-9]|[1-9]|)(\.\d\d))$")
        RegExpression1 = New Regex("^((100)|([1-9][0-9]|[1-9]|))$")
        If RegExpression.IsMatch(TextBox3.Text) Or RegExpression1.IsMatch(TextBox3.Text) Then
            If TextBox3.Text <> "" Then
                Dim Dec As Double = CDbl(TextBox1.Text) * CDbl(TextBox3.Text) / 100
                Dec = Math.Round(CDbl(Dec), 2, MidpointRounding.ToEven)
                TextBox2.Text = Dec.ToString()
                Dim result As Double = Math.Round(Dec, 0, MidpointRounding.AwayFromZero)
                TextBox4.Text = result.ToString()
            End If
            MsgBox("Not a match!")
            TextBox3.Text = ""
        End If


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend