Esempio n. 1
0
        static double GetValueFromUser(string val)
        {
            string strValue;

            for (; ;)
            {
                Console.Write("Введите число (" + val + ") :");
                strValue = Console.ReadLine();
                if (strValue != String.Empty)
                {
                    double tempV = 0;

                    int valErr = 0;

                    try
                    {
                        valErr = QETools.ParseValue(strValue, ref tempV);
                        if (valErr == 0)
                        {
                            if (val == "a")
                            {
                                if (tempV == 0)
                                {
                                    ErrorMessage(val, 4);
                                }
                                else
                                {
                                    return(tempV);
                                }
                            }
                            else
                            {
                                return(tempV);
                            }
                        }
                        else
                        {
                            ErrorMessage(val, valErr);
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorMessage(ex.Message, 3);
                    }
                }
            }
        }
Esempio n. 2
0
        private int GetValueFromUser(TextBox txb, string koef, ref double val)
        {
            int valErr = 0;
            int count  = 0;

            if (txb.Text != String.Empty)
            {
                try
                {
                    valErr = QETools.ParseValue(txb.Text, ref val);
                }
                catch (Exception ex)
                {
                    messageError      += "Произошла непредвиденная ошибка. Повторите ввод. \n";
                    txb.Text           = String.Empty;
                    this.ActiveControl = txb;
                    count = 1;
                }
                if (valErr != 0)
                {
                    messageError      += MessageError(koef, valErr);
                    txb.Text           = String.Empty;
                    this.ActiveControl = txb;
                    count = 1;
                }
            }
            else
            {
                count              = 1;
                messageError      += "Вы не ввели значение (" + koef + ") .Повторите ввод.\n";
                this.ActiveControl = txb;
                val = -1;
            }


            return(count);
        }