تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
تطبيق العمليات الحسابية بمرونة (Real Dynamic Calculate) -مـا بعد التطوير-
#1
كاتب الموضوع : Programmation

الســلام عليكم ورحمة الله وبركاته

إخــواني الأعضاء الكرام, كيف حال الجميع؟

اسـأل الله العظيم أن تكونوا فى أفضل حال وأتم عافية.

كُنت قد قمت من فترة بكتابة مقال لحساب المعادلات الحسابية كاملة فى مرة واحدة


ولكن فى ذلك المقال لم أُراعي الأقواس وكذلك ترتيب العمليات الحسابية حتى يخرج الناتج بشكل صحيح وهذا ما حدث وبصراحة من نبهني لذلك هو الأستاذ IslamIbrahim, أما الأن فقد قمت بتطوير الأمر بعمل Class Library كامل يُعالج تلك المعادلات بما فيها من أقواس وترتيباً للعمليات الحسابية بطريقة صحيحة (حساب ما داخل الأقواس, حساب ما بخارج الأقواس, ترتيباً لـ حساب الأس ثُم حساب الضرب ثُم حساب القسمة ثُم حساب الطرح وأخيراً حساب الجمع).


وهـا هو الـ Class Library كاملاً:


كود :
[color=#000000][COLOR=#0000bb][/color][COLOR=#dd0000]'About Author:  
'[/COLOR][color=#0000bb]Name[/color][color=#007700]: [/color][color=#0000bb]Programmation[/color][color=#007700]([/color][color=#0000bb]OmarNegm[/color][COLOR=#007700]),  
[/COLOR][COLOR=#dd0000]'Country: Egypt,  
'[/COLOR][color=#0000bb]E_mail[/color][color=#007700]: [/color][color=#0000bb]Programmation2000[/color][color=#007700]@[/color][color=#0000bb]hotmail[/color][color=#007700].[/color][COLOR=#0000bb]com
Imports System
Imports System[/COLOR][color=#007700].[/color][COLOR=#0000bb]Text
[/COLOR][color=#007700]Public Class [/color][COLOR=#0000bb]clsCalculate
    [/COLOR][color=#007700]Const [/color][color=#0000bb]addMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"+"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]powerMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"^"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]divideMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"/"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]percentMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"%"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]multiplyMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"*"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]subtractMark [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"_"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]leftParenttheses [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]")"
    [/COLOR][color=#007700]Const [/color][color=#0000bb]rightParenttheses [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"("
    [/COLOR][color=#0000bb]Dim UserPassedStatement [/color][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#dd0000]""
    [/COLOR][color=#0000bb]Dim CalculateMathStatement [/color][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#dd0000]""
    [/COLOR][color=#0000bb]Dim AllParentThesesStatements [/color][color=#007700]As [/color][color=#0000bb]StringBuilder [/color][color=#007700]= New [/color][COLOR=#0000bb]StringBuilder
    [/COLOR][color=#007700]Public Function [/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#0000bb]ByVal MathStatement [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700], [/color][color=#0000bb]Optional ByRef strLogs [/color][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][color=#dd0000]""[/color][color=#007700]) As [/color][COLOR=#0000bb]Double
        Dim Logs[/COLOR][color=#007700]() As [/color][COLOR=#0000bb]String
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]Double [/color][color=#007700]= [/color][COLOR=#0000bb]0.0
        [/COLOR][COLOR=#007700]Try
            [/COLOR][color=#0000bb]UserPassedStatement [/color][color=#007700]= [/color][color=#0000bb]RemoveSpaces[/color][color=#007700]([/color][color=#0000bb]MathStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]UserPassedStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]RemoveSpaces[/color][color=#007700]([/color][color=#0000bb]MathStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]HandlNegativeMark[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Call GetAllParentThesesStatements[/color][COLOR=#007700]()
            [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]HandlNegativeMark[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]Calculate[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][color=#007700], [/color][color=#0000bb]False[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#dd0000]"|=" [/color][color=#007700]& [/color][color=#0000bb]Result[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Logs [/color][color=#007700]= [/color][color=#0000bb]Split[/color][color=#007700]([/color][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700], [/color][color=#dd0000]"|"[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]strLogs [/color][color=#007700]= [/color][COLOR=#dd0000]""
            [/COLOR][color=#007700]For [/color][color=#0000bb]i [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]0 To UBound[/color][color=#007700]([/color][color=#0000bb]Logs[/color][COLOR=#007700])
                If [/COLOR][color=#0000bb]strLogs[/color][color=#007700].[/color][color=#0000bb]Trim [/color][color=#007700]= [/color][color=#dd0000]"" [/color][COLOR=#0000bb]Then
                    strLogs [/COLOR][color=#007700]= [/color][color=#0000bb]Logs[/color][color=#007700]([/color][color=#0000bb]i[/color][COLOR=#007700])
                Else
                    [/COLOR][color=#0000bb]strLogs [/color][color=#007700]&= [/color][color=#0000bb]vbNewLine [/color][color=#007700]& [/color][color=#0000bb]Logs[/color][color=#007700]([/color][color=#0000bb]i[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
            [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]Catch [/color][color=#0000bb]ex [/color][color=#007700]As [/color][COLOR=#0000bb]Exception
            MessageBox[/COLOR][color=#007700].[/color][color=#0000bb]Show[/color][color=#007700]([/color][color=#dd0000]"Input Math String is Incorrect Format!"[/color][color=#007700], [/color][color=#dd0000]"Error"[/color][color=#007700], [/color][color=#0000bb]MessageBoxButtons[/color][color=#007700].[/color][color=#0000bb]OK[/color][color=#007700], [/color][color=#0000bb]MessageBoxIcon[/color][color=#007700].[/color][color=#0000bb]Exclamation[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]0
        End [/COLOR][COLOR=#007700]Try
        Return [/COLOR][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]HandlNegativeMark[/color][color=#007700]([/color][color=#0000bb]ByVal strMath [/color][color=#007700]As [/color][color=#0000bb]String[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Dim Negative [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]"-"
        [/COLOR][color=#0000bb]Dim currentChat [/color][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]""
        [/COLOR][color=#0000bb]Dim Result [/color][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#0000bb]strMath
ReDo[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]i [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]Negative Then
                [/COLOR][color=#007700]If [/color][color=#0000bb]i [/color][color=#007700]> [/color][COLOR=#0000bb]1 Then
                    [/COLOR][color=#007700]If [/color][color=#0000bb]IsNumeric[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#0000bb]True [/color][color=#007700]Or [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]leftParenttheses Then
                        Result [/COLOR][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700])
                        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]subtractMark[/color][COLOR=#007700])
                        [/COLOR][COLOR=#0000bb]GoTo ReDo
                    End [/COLOR][COLOR=#007700]If
                [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]RemoveSpaces[/color][color=#007700]([/color][color=#0000bb]ByVal strMath [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700]) As [/color][COLOR=#0000bb]String
        Dim Space [/COLOR][color=#007700]As [/color][color=#0000bb]Char [/color][color=#007700]= [/color][COLOR=#dd0000]" "
        [/COLOR][color=#0000bb]Dim Result [/color][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#0000bb]strMath
ReDo[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]Space Then
                Result [/COLOR][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo ReDo
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]ByVal Start [/color][color=#007700]As [/color][color=#0000bb]Integer[/color][color=#007700], [/color][color=#0000bb]ByVal strString [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700]) As [/color][COLOR=#0000bb]Integer
        Dim I [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        [/COLOR][color=#007700]For [/color][color=#0000bb]I [/color][color=#007700]= [/color][color=#0000bb]Start To strString[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]IsNumeric[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#0000bb]True [/color][color=#007700]Or [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#dd0000]"-" [/color][color=#007700]Or [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#dd0000]"." [/color][COLOR=#0000bb]Then
                Result [/COLOR][color=#007700]+= [/color][COLOR=#0000bb]1
            [/COLOR][COLOR=#007700]Else
                Exit For
            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]If [/color][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]0 Then Result [/color][color=#007700]= [/color][COLOR=#0000bb]1
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]ByVal Start [/color][color=#007700]As [/color][color=#0000bb]Integer[/color][color=#007700], [/color][color=#0000bb]ByVal strString [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700]) As [/color][COLOR=#0000bb]Integer
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim I [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]Start
        [/COLOR][color=#007700]Do [/color][color=#0000bb]Until I [/color][color=#007700]= [/color][COLOR=#0000bb]1
            I [/COLOR][color=#007700]-= [/color][COLOR=#0000bb]1
            [/COLOR][color=#007700]If [/color][color=#0000bb]IsNumeric[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#0000bb]True [/color][color=#007700]Or [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#dd0000]"-" [/color][color=#007700]Or [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strString[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][color=#dd0000]"." [/color][COLOR=#0000bb]Then
                Result [/COLOR][color=#007700]+= [/color][COLOR=#0000bb]1
            [/COLOR][COLOR=#007700]Else
                Exit Do
            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Loop
        [/COLOR][color=#007700]If [/color][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]0 Then Result [/color][color=#007700]= [/color][COLOR=#0000bb]1
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]FilterAllToAddProcess[/color][color=#007700]([/color][color=#0000bb]ByVal strMath [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700]) As [/color][COLOR=#0000bb]String
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#0000bb]strMath        
        Dim dblCalculate [/COLOR][color=#007700]As [/color][color=#0000bb]Double [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim RighLength [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim LeftLength [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
ReDo[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]percentMark Then
                RighLength [/COLOR][color=#007700]= [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])      
                [/COLOR][color=#0000bb]dblCalculate [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength[/color][color=#007700], [/color][color=#0000bb]RighLength[/color][color=#007700])) / [/color][COLOR=#0000bb]100
                Result [/COLOR][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700], [/color][color=#0000bb]RighLength [/color][color=#007700]+ [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo ReDo
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
ReDo1[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]powerMark Then
                RighLength [/COLOR][color=#007700]= [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]LeftLength [/color][color=#007700]= [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]dblCalculate [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength[/color][color=#007700], [/color][color=#0000bb]RighLength[/color][color=#007700])) ^ [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LeftLength[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700], [/color][color=#0000bb]RighLength [/color][color=#007700]+ [/color][color=#0000bb]LeftLength [/color][color=#007700]+ [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo ReDo1
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
RoDo2[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]multiplyMark Then
                RighLength [/COLOR][color=#007700]= [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]LeftLength [/color][color=#007700]= [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]dblCalculate [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength[/color][color=#007700], [/color][color=#0000bb]RighLength[/color][color=#007700])) * [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LeftLength[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700], [/color][color=#0000bb]RighLength [/color][color=#007700]+ [/color][color=#0000bb]LeftLength [/color][color=#007700]+ [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo RoDo2
            End [/COLOR][COLOR=#007700]If            
        [/COLOR][COLOR=#0000bb]Next
ReDo3[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]divideMark Then
                RighLength [/COLOR][color=#007700]= [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]LeftLength [/color][color=#007700]= [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]dblCalculate [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength[/color][color=#007700], [/color][color=#0000bb]RighLength[/color][color=#007700])) / [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LeftLength[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700], [/color][color=#0000bb]RighLength [/color][color=#007700]+ [/color][color=#0000bb]LeftLength [/color][color=#007700]+ [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo ReDo3
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next

ReDo4[/COLOR][COLOR=#007700]:
        For [/COLOR][color=#0000bb]I [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To Result[/color][color=#007700].[/color][COLOR=#0000bb]Length
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]subtractMark Then
                RighLength [/COLOR][color=#007700]= [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]I[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])
                [/COLOR][color=#0000bb]LeftLength [/color][color=#007700]= [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Result[/color][COLOR=#007700])                                
                [/COLOR][color=#0000bb]dblCalculate [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength[/color][color=#007700], [/color][color=#0000bb]RighLength[/color][color=#007700])) - [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]Result[/color][color=#007700], [/color][color=#0000bb]I [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LeftLength[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][COLOR=#007700]))
                [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]I [/color][color=#007700]- [/color][color=#0000bb]RighLength [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]dblCalculate[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700], [/color][color=#0000bb]RighLength [/color][color=#007700]+ [/color][color=#0000bb]LeftLength [/color][color=#007700]+ [/color][color=#0000bb]1[/color][COLOR=#007700])
                [/COLOR][COLOR=#0000bb]GoTo ReDo4
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
    Private Function [/COLOR][color=#0000bb]Calculate[/color][color=#007700]([/color][color=#0000bb]ByVal strMath [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700], [/color][color=#0000bb]ByVal Have_A_Parentheses [/color][color=#007700]As [/color][color=#0000bb]Boolean[/color][color=#007700]) As [/color][COLOR=#0000bb]Double
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]Double [/color][color=#007700]= [/color][COLOR=#0000bb]0
        [/COLOR][color=#007700]If [/color][color=#0000bb]Have_A_Parentheses [/color][color=#007700]= [/color][COLOR=#0000bb]True Then
            strMath [/COLOR][color=#007700]= [/color][color=#0000bb]strMath[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]0[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700])
            [/COLOR][color=#0000bb]strMath [/color][color=#007700]= [/color][color=#0000bb]strMath[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700].[/color][color=#0000bb]Length [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
        [/COLOR][color=#0000bb]strMath [/color][color=#007700]= [/color][color=#0000bb]FilterAllToAddProcess[/color][color=#007700]([/color][color=#0000bb]strMath[/color][COLOR=#007700])
        If [/COLOR][color=#0000bb]strMath[/color][color=#007700].[/color][color=#0000bb]Length [/color][color=#007700]= [/color][color=#0000bb]1 [/color][color=#007700]And [/color][color=#0000bb]IsNumeric[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700]) = [/color][COLOR=#0000bb]True Then
            Result [/COLOR][color=#007700]= [/color][color=#0000bb]CDbl[/color][color=#007700]([/color][color=#0000bb]strMath[/color][COLOR=#007700])
        ElseIf [/COLOR][color=#0000bb]IsNumeric[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700]) = [/color][COLOR=#0000bb]True Then
            Result [/COLOR][color=#007700]= [/color][color=#0000bb]CDbl[/color][color=#007700]([/color][color=#0000bb]strMath[/color][COLOR=#007700])
            [/COLOR][COLOR=#0000bb]GoTo SinglValue
        [/COLOR][COLOR=#007700]Else            
            For [/COLOR][color=#0000bb]i [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]1 To strMath[/color][color=#007700].[/color][COLOR=#0000bb]Length
                Select [/COLOR][color=#007700]Case [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]1[/color][COLOR=#007700]))
                    Case [/COLOR][COLOR=#0000bb]addMark
                        [/COLOR][color=#007700]If [/color][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]0 Then
                            [/COLOR][color=#007700]If [/color][color=#0000bb]Have_A_Parentheses [/color][color=#007700]= [/color][COLOR=#0000bb]False Then
                                [/COLOR][color=#007700]If [/color][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]ToString [/color][color=#007700]= [/color][color=#dd0000]"" [/color][COLOR=#0000bb]Then
                                    AllParentThesesStatements[/COLOR][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]), [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]))) & [/color][color=#dd0000]"+" [/color][color=#007700]& [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700]))))
                                Else
                                    [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#dd0000]"|"[/color][COLOR=#007700])
                                    [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]), [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]))) & [/color][color=#dd0000]"+" [/color][color=#007700]& [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700]))))
                                [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                            [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]), [/color][color=#0000bb]RNumberLength[/color][color=#007700]([/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]strMath[/color][color=#007700]))) + [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700])))
                            [/COLOR][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700])
                        Else
                            If [/COLOR][color=#0000bb]Have_A_Parentheses [/color][color=#007700]= [/color][COLOR=#0000bb]False Then
                                [/COLOR][color=#007700]If [/color][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]ToString [/color][color=#007700]= [/color][color=#dd0000]"" [/color][COLOR=#0000bb]Then
                                    AllParentThesesStatements[/COLOR][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]Result [/color][color=#007700]& [/color][color=#dd0000]"+" [/color][color=#007700]& [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700]))))
                                Else
                                    [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#dd0000]"|"[/color][COLOR=#007700])
                                    [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]Result [/color][color=#007700]& [/color][color=#dd0000]"+" [/color][color=#007700]& [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700]))))
                                [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                            [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                            [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][color=#0000bb]Result [/color][color=#007700]+ [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToDouble[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]strMath[/color][color=#007700], [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700])))
                            [/COLOR][color=#0000bb]i [/color][color=#007700]= [/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]LNumberLength[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]+ [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]strMath[/color][COLOR=#007700])
                        [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                [/COLOR][COLOR=#0000bb]End Select
            Next
        End [/COLOR][COLOR=#007700]If
[/COLOR][color=#0000bb]SinglValue[/color][COLOR=#007700]:
        Return [/COLOR][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function        
    Private [/COLOR][color=#0000bb]Sub GetAllParentThesesStatements[/color][COLOR=#007700]()
        [/COLOR][color=#0000bb]Dim cmsLength [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim FirstRightOne [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim SourceParenttheses [/COLOR][color=#007700]As [/color][color=#0000bb]String [/color][color=#007700]= [/color][COLOR=#dd0000]""
        [/COLOR][color=#0000bb]Dim CalculatedPatrenttheses [/color][color=#007700]As [/color][color=#0000bb]Double [/color][color=#007700]= [/color][COLOR=#0000bb]0
ReDo[/COLOR][COLOR=#007700]:
        Do [/COLOR][color=#0000bb]Until GetFirstRightParenttheses[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][color=#007700]) = [/color][COLOR=#0000bb]0
            cmsLength [/COLOR][color=#007700]= [/color][color=#0000bb]CalculateMathStatement[/color][color=#007700].[/color][COLOR=#0000bb]Length
            FirstRightOne [/COLOR][color=#007700]= [/color][color=#0000bb]GetFirstRightParenttheses[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][COLOR=#007700])
            For [/COLOR][color=#0000bb]i [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]FirstRightOne To cmsLength
                [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]leftParenttheses Then
                    SourceParenttheses [/COLOR][color=#007700]= [/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]CalculateMathStatement[/color][color=#007700], [/color][color=#0000bb]FirstRightOne[/color][color=#007700], [/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]FirstRightOne[/color][color=#007700]) + [/color][color=#0000bb]1[/color][COLOR=#007700])
                    [/COLOR][color=#0000bb]CalculatedPatrenttheses [/color][color=#007700]= [/color][color=#0000bb]Calculate[/color][color=#007700]([/color][color=#0000bb]SourceParenttheses[/color][color=#007700], [/color][color=#0000bb]True[/color][COLOR=#007700])
                    If [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700].[/color][color=#0000bb]Trim [/color][color=#007700]= [/color][color=#dd0000]"" [/color][COLOR=#0000bb]Then
                        AllParentThesesStatements[/COLOR][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]SourceParenttheses [/color][color=#007700]& [/color][color=#dd0000]"=" [/color][color=#007700]& [/color][color=#0000bb]CalculatedPatrenttheses[/color][COLOR=#007700])
                    Else
                        [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#dd0000]"|"[/color][COLOR=#007700])
                        [/COLOR][color=#0000bb]AllParentThesesStatements[/color][color=#007700].[/color][color=#0000bb]Append[/color][color=#007700]([/color][color=#0000bb]SourceParenttheses [/color][color=#007700]& [/color][color=#dd0000]"=" [/color][color=#007700]& [/color][color=#0000bb]CalculatedPatrenttheses[/color][COLOR=#007700])
                    [/COLOR][color=#0000bb]End [/color][COLOR=#007700]If
                    [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]CalculateMathStatement[/color][color=#007700].[/color][color=#0000bb]Insert[/color][color=#007700]([/color][color=#0000bb]FirstRightOne [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700], [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]CalculatedPatrenttheses[/color][COLOR=#007700]))
                    [/COLOR][color=#0000bb]CalculateMathStatement [/color][color=#007700]= [/color][color=#0000bb]CalculateMathStatement[/color][color=#007700].[/color][color=#0000bb]Remove[/color][color=#007700]([/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]FirstRightOne [/color][color=#007700]- [/color][color=#0000bb]1[/color][color=#007700]) + [/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToString[/color][color=#007700]([/color][color=#0000bb]CalculatedPatrenttheses[/color][color=#007700]).[/color][color=#0000bb]Length[/color][color=#007700]), [/color][color=#0000bb]Val[/color][color=#007700]([/color][color=#0000bb]i [/color][color=#007700]- [/color][color=#0000bb]FirstRightOne[/color][color=#007700]) + [/color][color=#0000bb]1[/color][COLOR=#007700])
                    [/COLOR][COLOR=#0000bb]GoTo ReDo
                End [/COLOR][COLOR=#007700]If
            [/COLOR][COLOR=#0000bb]Next
        Loop    
    End Sub    
    [/COLOR][color=#007700]Private Function [/color][color=#0000bb]GetFirstRightParenttheses[/color][color=#007700]([/color][color=#0000bb]ByVal MathStatement [/color][color=#007700]As [/color][color=#0000bb]String[/color][color=#007700]) As [/color][COLOR=#0000bb]Integer
        Dim Result [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]0
        Dim msLength [/COLOR][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][color=#0000bb]MathStatement[/color][color=#007700].[/color][COLOR=#0000bb]Length
        [/COLOR][color=#007700]For [/color][color=#0000bb]i [/color][color=#007700]As [/color][color=#0000bb]Integer [/color][color=#007700]= [/color][COLOR=#0000bb]1 To msLength
            [/COLOR][color=#007700]If [/color][color=#0000bb]Convert[/color][color=#007700].[/color][color=#0000bb]ToChar[/color][color=#007700]([/color][color=#0000bb]Mid[/color][color=#007700]([/color][color=#0000bb]MathStatement[/color][color=#007700], [/color][color=#0000bb]i[/color][color=#007700], [/color][color=#0000bb]1[/color][color=#007700])) = [/color][COLOR=#0000bb]rightParenttheses Then
                Result [/COLOR][color=#007700]= [/color][COLOR=#0000bb]i
            End [/COLOR][COLOR=#007700]If
        [/COLOR][COLOR=#0000bb]Next
        [/COLOR][color=#007700]Return [/color][COLOR=#0000bb]Result
    End [/COLOR][COLOR=#007700]Function
[/COLOR][color=#0000bb]End [/color][COLOR=#007700]Class  
[/COLOR][color=#0000bb][/color][/COLOR]

أمثلة لإســتخدام الـ Class:

تحتوي الـ Class على Function رئيسي "RealDynamicCalculate" هو الوحيد المُعلن عنه بـ Public أي الوحيد الذي يُمكن الوصول إليه من خلال الـ Class تلك الـ Function تقوم بعمل كل شئ من الألف إلى الياء وأنت لست بحاجة لسـواها, فباقي الـ Functions والـ Method لتطبيق العملية مرحلة تلي الأخرى.

تحتوي تلك الـFunction على معامين (Parameters) فقط, الأول فهو إجباري ومن نوع String ويُمرر إليه نص المعادلة, وأما الثاني فهو إختياري ومن نوع String أيضاً ولكن معامل مرجعي "Reference Parameter" ويُممر إليه النص الذى سوف يحمل مراحل حساب المعادلة جميعاً (Function Logs) حيث يعود إليك بنص يحتوي على كل حساب لأي من مراحل المُعادلة بادئاً بحساب الأقواس ثُم ما بخارجها, حتى يوضح لك طبيعة ومراحل عمل الحسـاب بإستخدام الـ Class. والحقيقة ما دعاني إلى أن أجعله مرجعي حتى تكون لديك الإمكانية بإسترجاع قيمته داخل نص TextBox أو متغير من نصي بدلاً من تمرير TextBox كامل (هذا أفضل) عموماً لن نختلف حيث أنه إختياري .


الأن مع أمثلة للإستــخدام:

1

كود :
[color=#000000][COLOR=#0000bb] Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"(100+100)-(100/100)"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]199  
[/COLOR][/COLOR]

OR

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"(100+100)-(100%)"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]199  
[/COLOR][/COLOR]

2

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"5^2*(24/2-2)"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]250  
[/COLOR][/COLOR]

3

كود :
[color=#000000][COLOR=#0000bb] Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"5^2*24/2"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]300  
[/COLOR][/COLOR]

4

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"90000-((5^2*24/2)^2)"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]0  
[/COLOR][/COLOR]

5

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"90000-((5^2*24/2)^2)+(90000/2)"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]45000  
[/COLOR][/COLOR]

6

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"((((90000-((5^2*24/2)^2)+(90000/2)))))-22500"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]22500  
[/COLOR][/COLOR]

7 مُستخدماً للمعامل الإختياري لمراحل العملية:

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"(1-1+((12*12) + (23-(-12)))-12+15*(2^3)+(70%)*(100)/2-(22))-200"[/color][color=#007700], [/color][color=#0000bb]txtLogs[/color][color=#007700].[/color][color=#0000bb]Text[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= [/color][COLOR=#0000bb]100  
[/COLOR][/COLOR]

8

كود :
[color=#000000][COLOR=#0000bb]Dim Calculator [/color][color=#007700]As New [/color][COLOR=#0000bb]clsCalculate
        txtResult[/COLOR][color=#007700].[/color][color=#0000bb]Text [/color][color=#007700]= [/color][color=#0000bb]Calculator[/color][color=#007700].[/color][color=#0000bb]RealDynamicCalculate[/color][color=#007700]([/color][color=#dd0000]"((-500)-(-200))"[/color][COLOR=#007700])
        [/COLOR][color=#0000bb]Result [/color][color=#007700]= -[/color][COLOR=#0000bb]300  
[/COLOR][/COLOR]


سأتركك الأن مع الـ Class,
وإذا في أي أستفسار أنا جاهز بإذن الله,
ولا تنسونا من صالح دُعــــــــــــــــــــــائكـم.


وفقك الله
}}}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  الجزء الثالث من:كيف تجعل الـ Text Box ذكي!يترجم العمليات الحسابية ويخرج الناتج (الأقواس المتعددة) !! أنس محمود 9 2,082 06-12-14, 10:11 PM
آخر رد: RFEE3 ALSHAN
  @@@ معالجة العمليات الحسابية من خلال مربع نص وإظهار النتيجة @@@ @@أبورائد@@ 9 1,595 25-05-13, 01:07 PM
آخر رد: shaker.soft
  الجزء الثاني من:كيف تجعل الـ Text Box ذكي!يترجم العمليات الحسابية ويخرج الناتج ( العمليات المتعددة)! أنس محمود 0 689 22-02-13, 12:39 AM
آخر رد: أنس محمود
  كيف تجعل الـ Text Box ذكي !! يترجم العمليات الحسابية ويخرج الناتج !! بالداخل المزيد !! أنس محمود 0 1,570 20-02-13, 12:58 AM
آخر رد: أنس محمود
  فصل العمليات الحسابية من النوع String، ( الجزء الثالث - عمليات الأقواس ) RaggiTech 0 526 04-10-12, 01:41 PM
آخر رد: RaggiTech
  فصل العمليات الحسابية ، واخراج الناتج ... الكثير . RaggiTech 0 484 04-10-12, 01:37 PM
آخر رد: RaggiTech
  فصل العمليات الحسابية من النوع String، ( الجزء الثاني - العمليات المتعددة ) RaggiTech 0 509 04-10-12, 01:27 PM
آخر رد: RaggiTech
  درس - كيف تصنع تطبيق Plug-Ins في في .Net RaggiTech 0 441 03-10-12, 01:59 PM
آخر رد: RaggiTech
  تطبيق تأثير الزجاج على الفيستا RaggiTech 0 294 03-10-12, 08:59 AM
آخر رد: RaggiTech
  تطبيق العمليات الحسابية بمرونة (فقط تكتب معادلتك) DynamicCalculate RaggiTech 1 465 03-10-12, 08:55 AM
آخر رد: RaggiTech

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم