Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Get a color name from any RGB combination?

Here's a userform I threw together that shows how to use
"dataset.txt"

https://app.box.com/s/23yqum8auvzx17h04u4f

Note that the file doesn't contain every possible RGB combination,
and so there's opportunity to add your own names. If interested, I
can import the parsed file into a worksheet and edit the values, then
export it a a csv.


After some thought (and a good night's sleep), I believe the userform
can be easily modified to 'Add' new names and RGB combos to the
"dataset.txt" file so it never actually needs to be loaded into a
worksheet.

I'm not sure what (if any) practical use this has other than say
designing custom paint colors, but it has captured my interest enough
that I started a XLS project named "ColorNameManager" which I will
provide a download link to when it's done to my satisfaction. This will
include a zip file containing the original "dataset.js" file and the
above named workbook in XLS format...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Get a color name from any RGB combination?

Way to go, Gary, and thank you so much for your effort :-)

I can't wait to see what you come up with :-)

I tried to download your userForm, but couldn't import it, since it seem to
be missing a .FMX file???

I'm currently working on a solution myself, so it'll be interesting to
compare :-)


Regards,

CE


"GS" wrote in message ...
Here's a userform I threw together that shows how to use "dataset.txt"

https://app.box.com/s/23yqum8auvzx17h04u4f

Note that the file doesn't contain every possible RGB combination, and so
there's opportunity to add your own names. If interested, I can import
the parsed file into a worksheet and edit the values, then export it a a
csv.


After some thought (and a good night's sleep), I believe the userform can
be easily modified to 'Add' new names and RGB combos to the "dataset.txt"
file so it never actually needs to be loaded into a worksheet.

I'm not sure what (if any) practical use this has other than say designing
custom paint colors, but it has captured my interest enough that I started
a XLS project named "ColorNameManager" which I will provide a download
link to when it's done to my satisfaction. This will include a zip file
containing the original "dataset.js" file and the above named workbook in
XLS format...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion





---
Denne e-mail er fri for virus og malware fordi avast! Antivirus beskyttelse er aktiveret.
http://www.avast.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Get a color name from any RGB combination?

Sorry about the userform issue. You could open the file in a text
editor and just copy/paste the code part into an empty userform code
window.

(The 'frx' file is a binary component of the same userform) The 'frm'
file is a VBA component exported as any other so I'm not understanding
why you can't just 'Import...' it into a project.

I decided there's no value to include the original dataset.js file
since it won't be used by the project once the txt file is created.
That means I'll include the txt file and XLS. Note that they must be
stored in the same folder because refs to the txt file are
'ThisWorkbook.Path'!

I'll post a link to the project later today (hopefully). Aside from
having the same ability to display color and name (if one exists) for
entered RGB values, it will also have the ability to
'Add/Remove/Rename'. If you want any other features included before I
finish it please post.

How it works: (In case you copy/paste the code)
RGB values and their respective names are stored in a plain text file.

Userform:
Loads data into a module-scope variant in its 'Initialize' event;
Caption: "Color Name Manager";

Controls:
3 textboxes (txtR, txtG, txtB) for entering RGB values;
3 labels (Red, Green, Blue) for the above textboxes;

1 textbox (txtColorName) for displaying/entering names;
1 label (Color Name) for the above textbox;

1 label (lblColor) for displaying the color as its 'BackColor';

Buttons:
Show Name
Displays the name of the RGB values entered.
If name doesn't exist, displays "Name Not Found" and prompts to
add a new name.
New Name
Remove (to be added)
Rename (to be added)
Done

These are managed as context-sensitive items via 'SetButtonState',
so you can only take appropriate actions.

The data is managed via editing the array during runtime;
The txt file is updated whenever a change in data occurs;

If you try adding a new name to existing RGB values you are prompted to
rename Yes/No.

If you try adding an existing name to non-existing RGB values you are
notified of this and prompted to change its RGB values Yes/No.

If you try to remove a name you are asked to confirm the action Yes/No.

Pressing the 'Escape' key unloads the userform.

I'm considering displaying the txt file contents in a listbox instead
of a worksheet. This will change the userform slightly to show 'pages'
for "RGB" and "Data" so you can view all existing data within the
userform instead of having to scroll a worksheet. If I go with this,
the listbox page will also have full editing capability. It occurs to
me, though, that I should build 3 userforms and let you choose which
one to go with...

Userform1: as described with the controls previously mentioned;
Userform2: listbox style with full editing capability;
Userform3: a 2-page that contains both versions;

...unless you post your preference before I finish!

<FWIW
I'm not a fan of textbox-based data forms (generally speaking) and so I
already have a listbox format I use for my projects. IMO, this is the
better way to go because it's less confusing to the user as to what's
being done exactly (or what/how to do an action). (I also have a
datagrid version and a ListView version that have non-scrolling header
rows, but these require the OCXs being shipped/registered on the host
machine and so aren't an option for a VBA project) I use 2 multi-column
listboxes; 1 for field headings and 1 for data. Editing of selected
data is done via textboxes. Selecting a name in the list will display
its color same as described earlier.

I'm inclined to use the color name as the primary key in the list,
followed by its respective RGB values. This makes sorting the list much
easier. (Names are easier to find in a sorted list)

Normally (to keep it simple) I'd use 1 column for names and 1 column
for the RGB values as a comma delimited list. The RGBs can have
separate columns if desired (please advise), but that means adding 2
more textboxes for editing (which is no problem).

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Get a color name from any RGB combination?

After a bit more thought I've decided to go with only the listbox
version. (You already have the info for the textbox version) This will
include separate columns for the RGB values so extra coding isn't
required for the RGB() function when displaying color. Also, the text
file is renamed "colornames.dat" and is sorted ascending!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom color for font color and or background shading color Ben[_14_] Excel Programming 2 May 5th 10 02:32 PM
combination combination? Excel Discussion (Misc queries) 10 January 13th 07 04:08 AM
Combination UsGrant_75 Charts and Charting in Excel 1 October 27th 06 08:04 PM
combination [email protected][_2_] Excel Programming 2 June 23rd 06 09:28 AM
combination deco Excel Programming 1 October 18th 05 06:40 PM


All times are GMT +1. The time now is 12:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"