|
The sixth band can be ignored like the tolerance band because it is an additional indicator for reliability or temperature coefficient. So handle it like a 5 band code. For 5 bands just enhance the code to support one more digit. With conversions from value to bands you should print out the result for 4 and 5 bands.
The smallest possible value that can be represented by color codes is 1 m / 0.1 m for 4 / 5 band codes. So there is no need for other units then mOhm. Even values smaller than 1 Ohm can be shown in Ohms because values below 0.1 Ohm are rather seldom with band codes. Resistors with small value (shunt resistors) usually have the value printed on the case.
|
|
|
|
|
Do I just need to add something below this:
Color.FromName(colours[res[0] - '0']);
Color.FromName(colours[res[1] - '0']);
Color.FromName(colours[third != 0 ? third : res.Count() - 2]);
|
|
|
|
|
No.
With one more digit you have to adjust the multiplier too.
BTW: You should post code here rather than providing an external link.
I did not checked if your code is working. But if so, you should have no problems to extent it to support one more digit. I would create two different functions to get the colors for 4 and 5 bands which are called after parsing and checking the input.
|
|
|
|
|
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 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))
{
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!");
}
}
|
|
|
|
|
I have problem when I enter value in uΩ,nΩ or pΩ.When I enter mΩ it is working good !!!
https://postimg.org/image/y6q4bw64d/
|
|
|
|
|
How to show closest standard value and closest standard color for resistor?
https://postimg.org/image/4gbzvpea5
https://postimg.org/image/q80yvq1uf
|
|
|
|
|
hi, i want to copy a text when i right click on a text in any windows anywhere, like babylon.
please help me and take me a simple code to do it?
|
|
|
|
|
What have you tried?
Where are you stuck?
And what does an ancient city have to do with it?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
|
Firstly, I doubt it will do what you want: the "text" it is talking about is probably the title, rather than the content. Windows can draw anything they like into themselves, it doesn't have to be related to any string based data.
Secondly, there is no "simple code" for this job: it's complicated for a reason, which is that it's a complicated task! I suspect that for what you want, it'll be even more complicated becuase you are goign to have to get involved with OCR and all sorts.
And thirdly, Babylon is an ancient city: https://en.wikipedia.org/wiki/Babylon[^] - and an important one.
It's also a browser hijacker toolbar, a former Iraqi project for the construction of superguns, a darknet market seized by law enforcement in July 2015, a design for space stations on TV, a strong and powerful (yet corrupted and immoral place) in Rastafarian religion, ... it may be a dictionary as well, but that's not its major claim to fame!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
my english is not good. please taked easy
no i dont want use of OCR i want just move the cursor on the one text and press right click And the text to be sent to a TextBox That 's it!
Ohh It is clear that this city is famous!! But my mean was Babylon Program.
|
|
|
|
|
It's not as simple as that: it the control is part of your app it's simple, but if it isn't then there may not be any accessible string component. Windows doesn't work like that - for example, Word is not a huge multi line text box, it draws a "chunk" of text from a tree of non-displaying class items which may or may not expose any text internally, much less externally.
What you want to do is not simple: it's extremely complicated and may only be possible if you take a "picture" of the window and use OCR to convert it to text.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thank, So How to Take a pic when i right click on a control? And Convert it a text with OCR? what library should i use for it?
modified 10-Oct-16 1:57am.
|
|
|
|
|
Your link doesn't work and we are not a write code to order service.
|
|
|
|
|
In C# 2005, I did not find lineControl, Have I be installed the wrong ? I want to have control I install them like ?
|
|
|
|
|
What are you talking about? I have no idea which LineControl you are talking about: what namespace should it be in, what does it do, how are you trying to use it? What environment is your app supposed to run for?
Remember that we can't see your screen, access your HDD, or read your mind.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
If you mean in WinForms ...
- Add a Label control to your form.
- Set Label Text to empty.
- Set BorderStyle to Fixed3D.
- Set AutoSize to false.
- Set Height to 2 (most easily accomplished by typing 2 into the Size/Height field under Label Properties).
|
|
|
|
|
Hi,
I am totally new to ASP.NET. Please help me to create a project to store persistent data.
Thanks
|
|
|
|
|
And you call your self a "senior" developer
Decide where you want to store the data (database or file system)
For database read up on creating a Web API project that uses a data access layer to connect t a database.
For file system read up on system.IO
No matter how you store the data you are going to have to research on what you intend to do.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: And you call your self a "senior" developer
Presumably, a "Very Senior Developer" is the one who can use Google...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
sunsher wrote: help me
How can we help you? Do you need help with a simple google search? Do you need help finding the search capabilities of CodeProject? Maybe need help finding the sticky post describing how to ask a question?
|
|
|
|
|
If you want help you need to be much more specific. What do you mean by persistent data? In ASP.Net you can store data in the application cache which persists as long as the process is running. You can store in a cookie which persists until it expires or is deleted. You can persist in the database or a file for however long you want.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Yes.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
To store data, you need to use a database of some sort.
ASP.Net can connect to many databases.
|
|
|
|
|
Would XML file work that way? And is it possible to use CRUD with XML?
|
|
|
|