//function that evaluates the expression inside the cell and returns the value as double
        private void UpdateCellValue(SpreadsheetCell c)
        {
            //get the expression inside the cell
            string expression = c.newCellText;
            string cellName   = Number2String(c.getColumn + 1, true);

            cellName += (c.getRow + 1).ToString();
            string vari = "";
            //parse the string in the exptree class taking out the = sign in the front of exp
            ExpTree tree = new ExpTree(expression.Substring(1));

            //delete thr reference cells
            c.listOfCells.Clear();
            //get all the variables inside the dictionary
            string[] variables = tree.getVar();
            foreach (string variable in variables)
            {
                if (variable.Length > 2)
                {
                    vari = variable;
                    break;
                }
                //all the columns are marked from A to Z so we have to convert that to int
                int col = Convert.ToInt32(variable[0] - 65);
                // remaining part is the name of the cell we need to copy a value from
                //to convert that
                int row = Convert.ToInt32(variable.Substring(1)) - 1;
                //add it to the reference cell list
                c.addReferences(SS_Array[row, col]);
                if (string.IsNullOrEmpty(SS_Array[row, col].newCellText))
                {
                    c.newCellText = "0";
                    c.Value       = "0";
                    break;
                }
                if (variable == cellName)
                {
                    vari = variable;
                    break;
                }
                tree.SetVar(variable, double.Parse(SS_Array[row, col].cellValue));
                SS_Array[row, col].PropertyChanged += c.OnVariableChange;
            }
            if (vari == cellName)
            {
                c.newCellText = "!(Self/Circular reference)";
                c.Value       = "!(Self/Circular reference)";
            }
            else if (vari.Length > 3)
            {
                c.newCellText = "!(Bad reference)";
                c.Value       = "!(Bad reference)";
            }
            else
            {
                //evaluate the expression
                double newVal = tree.Eval();
                c.Value = newVal.ToString();
            }
        }