Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
Questionhow to read mbr Pin
Member 124586219-Oct-16 2:00
Member 124586219-Oct-16 2:00 
AnswerRe: how to read mbr Pin
NotPolitcallyCorrect9-Oct-16 2:19
NotPolitcallyCorrect9-Oct-16 2:19 
AnswerRe: how to read mbr Pin
OriginalGriff9-Oct-16 2:24
mveOriginalGriff9-Oct-16 2:24 
QuestionResistor color code Pin
Pavlex48-Oct-16 23:34
Pavlex48-Oct-16 23:34 
AnswerRe: Resistor color code Pin
Jochen Arndt9-Oct-16 0:44
professionalJochen Arndt9-Oct-16 0:44 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 0:48
Pavlex49-Oct-16 0:48 
GeneralRe: Resistor color code Pin
Jochen Arndt9-Oct-16 1:09
professionalJochen Arndt9-Oct-16 1:09 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 1:11
Pavlex49-Oct-16 1:11 
C#
private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "4")
            {
                if (textBox1.Text == "0")
                    MessageBox.Show("Otpornost mora biti veca od nule", "Otpornost", MessageBoxButtons.OK, MessageBoxIcon.Error);
 
              //  var black = Color.Black;
 
 
 
                var colours = new string[] { "Black", "Brown", "Red", "Orange", "Yellow", "Green", "Blue", "Violet", "Grey", "Silver", "Gold" };
                var factorDictionary = new Dictionary<char, int>() { { 'R', 1 }, { 'K', 1000 }, { 'M', 1000000 }, { 'G', 1000000000 } };
                string res = string.Empty;
 
                while (string.IsNullOrEmpty(res))
                {
                  //  MessageBox.Show("Enter resistor value (use R, K, M ,G notation for .): ");
                    res = textBox1.Text;
                }
 
                var lastChar = res.Last();
                var isUnitCorrect = factorDictionary.ContainsKey(lastChar);
                var value = res.Substring(0, res.Length - 1);
                var isValueCorrect = !value.Any(x => !char.IsDigit(x));
 
                if (isUnitCorrect && isValueCorrect)
                {
                    int mul = factorDictionary[lastChar];
                    double val = double.Parse(value) * mul;
                    int third = 0;
 
                    if (val < 1)
                    {
                        val *= 100;
                        third = 9;
                    }
                    else if (val < 10)
                    {
                        val *= 10;
                        third = 10;
                    }
 
                    res = val.ToString();
 
                    if (res.Count() > 11)
                        MessageBox.Show("Invalid value");
                    else
                    {
                        label15.BackColor = Color.FromName(colours[res[0] - '0']);
                        label16.BackColor = Color.FromName(colours[res[1] - '0']);
                        label17.BackColor = Color.FromName(colours[third != 0 ? third : res.Count() - 2]);
                    }
                }
                else
                    MessageBox.Show("Invalid value!");
            }
        }

GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 7:31
Pavlex49-Oct-16 7:31 
GeneralRe: Resistor color code Pin
Pavlex49-Oct-16 12:21
Pavlex49-Oct-16 12:21 
QuestionCopy the text of any windows anywhere Pin
Daniyaltjm8-Oct-16 0:29
Daniyaltjm8-Oct-16 0:29 
AnswerRe: Copy the text of any windows anywhere Pin
OriginalGriff8-Oct-16 0:56
mveOriginalGriff8-Oct-16 0:56 
GeneralRe: Copy the text of any windows anywhere Pin
Daniyaltjm9-Oct-16 5:24
Daniyaltjm9-Oct-16 5:24 
GeneralRe: Copy the text of any windows anywhere Pin
OriginalGriff9-Oct-16 5:50
mveOriginalGriff9-Oct-16 5:50 
GeneralRe: Copy the text of any windows anywhere Pin
Daniyaltjm9-Oct-16 6:12
Daniyaltjm9-Oct-16 6:12 
GeneralRe: Copy the text of any windows anywhere Pin
OriginalGriff9-Oct-16 6:23
mveOriginalGriff9-Oct-16 6:23 
GeneralRe: Copy the text of any windows anywhere Pin
Daniyaltjm9-Oct-16 6:59
Daniyaltjm9-Oct-16 6:59 
GeneralRe: Copy the text of any windows anywhere Pin
NotPolitcallyCorrect9-Oct-16 5:50
NotPolitcallyCorrect9-Oct-16 5:50 
QuestionLine Control in C# 2005 ? Pin
Member 24584677-Oct-16 18:01
Member 24584677-Oct-16 18:01 
AnswerRe: Line Control in C# 2005 ? Pin
OriginalGriff7-Oct-16 19:39
mveOriginalGriff7-Oct-16 19:39 
AnswerRe: Line Control in C# 2005 ? Pin
Garth J Lancaster8-Oct-16 23:48
professionalGarth J Lancaster8-Oct-16 23:48 
QuestionStore persistent data Pin
sunsher6-Oct-16 15:25
sunsher6-Oct-16 15:25 
AnswerRe: Store persistent data Pin
Mycroft Holmes6-Oct-16 20:09
professionalMycroft Holmes6-Oct-16 20:09 
GeneralRe: Store persistent data Pin
OriginalGriff6-Oct-16 22:30
mveOriginalGriff6-Oct-16 22:30 
AnswerRe: Store persistent data Pin
NotPolitcallyCorrect6-Oct-16 23:45
NotPolitcallyCorrect6-Oct-16 23:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.