Question Resistor color code

Pavle

Well-known member
Joined
Oct 4, 2016
Messages
47
Programming Experience
1-3
I made resistor app that calculates resistance from colors but I don't know how to make app that coverts resistance to color.Can you help me make this?
 
I made resistor app that calculates resistance from colors but I don't know how to make app that coverts resistance to color.Can you help me make this?
Are you talking about getting a value from the Color enumeration if you have a number?
Like var MyColor = Color.Black?
 
There's no magic to it. How would you do it manually? You'd look it up in a list. That's exactly how you would do it in code. If there's no mathematical formula that you can implement then the only option is lookup lists. I'm guessing that a Dictionary might be useful.
 
Where I can get dictionary for resistors?

There is no such thing existing that I'm aware of. You have to build it with your code, from the knowledge that you have of resistors. You're still looking for the magic solution that doesn't exist.
 
How to show color instead of text. For example, if I enter 15K it shows me brown,green and orange color, not text.
 
It depends on exactly how you want those colours displayed but the obvious thing that comes to mind is a number of controls, e.g. Labels, with their BackColor set appropriately.
 
That code doesn't print anything. It displays some text in a TextBox. As the name suggests, a TextBox is a box for displaying and inputting text. You don't want to do either of those things so TextBoxes are irrelevant. I've already provided one option for displaying colours. Unless there's some reason not to, use that. If there is a reason not to use that, what is that reason?
 
When I set label15.BackColor=colours(res[0] - '0')
I get error cannot implicitly convert type string to System.Drawing.Color
 
The BackColor property is type Color. You have to assign a Color value to it. I suggest that you go back and read all the replies in this thread and use all the information already provided.
 
Back
Top Bottom