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