C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Using Simple Maths Expressions Like X+100+20


Posted Date: 25 Sep 2008    Resource Type: Code Snippets    Category: VB.NET Syntax

Posted By: Initiotech       Member Level: Gold
Rating:     Points: 10



This simple application will take an input from the user in a expression format example "x+200+10" or "x-200-10"

The code works like this
First My Application will check what opperator the expression contains

If s.Contains("+") Then
Dim exp As String = s.Replace("x", x)
Dim nums() As String = exp.Split("+")
Console.WriteLine("Number of Operands are : " & nums.Length)
Dim sum As Integer
For Each x1 As String In nums
Dim num As Integer = x1
sum += num
Next
Console.WriteLine("The Solution for this Expression is : " & sum)
End If

If s.Contains("-") Then
Dim exp As String = s.Replace("x", x)
Dim nums() As String = exp.Trim.Split("-")
Console.WriteLine("Number of Operands are : " & nums.Length)
Dim subs As Integer
For Each x1 As String In nums
Dim num As Integer = x1
subs -= num
Next
Console.WriteLine("The Solution for this Expression is : " & subs)
End If

If s.Contains("*") Then
Dim exp As String = s.Replace("x", x)
Dim nums() As String = exp.Trim.Split("*")
Console.WriteLine("Number of Operands are : " & nums.Length)
Dim mul As Integer
For Each x1 As String In nums
Dim num As Integer = x1
mul *= num
Next
Console.WriteLine("The Solution for this Expression is : " & mul)
End If



Simple Code You may implement this code to solve big equations.

Regards Hefin Dsouza

Attachments

  • Download (21467-251028-UsingMathsExpressions.rar)



  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Expressions  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Creating Splash Screen in VB.NET using Form
    Previous Resource: Simple Note Pad Like Application
    Return to Discussion Resource Index
    Post New Resource
    Category: VB.NET Syntax


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers   BizTalk Adaptors    Web Design

    doors in nj

    Contact Us    Privacy Policy    Terms Of Use