PDA

View Full Version : Use the 2 colors to differentiate the Run File and Undo File in listbox



Ann_BBO
08-08-2007, 12:46 AM
How to write the vba to use the 2 colors to differentiate the 2 type of files in the listbox. One type is the file which had analysis (Black color)and other type is the file which had not analysis (just input the file in listbox)(Purple color).
Private Sub cmdInput_Click()
For i = LBound(sFiles) To UBound(sFiles)
sFileShort = Right(sFiles(i), Len(sFiles(i)))
With Me.ListBox1
.MultiSelect = 2
.ForeColor = RGB(128, 0, 255)
.AddItem sFileShort
.List(.ListCount - 1, 1) = sFiles(i)
End With
Next i
End sub

Private Sub cmdShowdata_Click()
.
ListBox1.List.ForeColor=RGB(0,0,0)
End sub

Thanks

Ann_BBO
08-08-2007, 01:35 AM
Have anyone tell me is it possible for the above thinking. It means un-analysis filelist(s) in listbox is purple-color and after analysis filelist(s) in listbox is black color.

Thanks

Ann_BBO
08-08-2007, 01:53 AM
I means that the observtion like this image
http://img262.imageshack.us/my.php?image=colorsinlistboxyf2.jpg

Ann_BBO
08-08-2007, 02:53 AM
Sorry, can anyone answer me the above "Sort the filelist in listbox by color" is work or not?
I had try my best to do it but not success. If this way is impossible, i will think another idea if not.

Regrads
Ann

Bob Phillips
08-08-2007, 03:26 AM
Don't think its possible.

Ann_BBO
08-08-2007, 03:30 AM
As my english is not good, do u means that it is impossible.
Anyway thanks your answer.

Regrads
Ann

Bob Phillips
08-08-2007, 03:35 AM
No, if I meant it was impossible, I would have said that it is impossible.

I said that I don't think it is possible because I know enough about listboxes to know that it is not a straight-forward option, and in all my experience, I have never come across a solution that would address it. That doesn't mean there isn't a solution out there, maybe an API solution lurking somewhere, but I haven't seen one or have the incentive to try and create one.

One should never say something is not possible, only that it IS possible or that one THINKS it is NOT possible. Asking to be shot down in flames otherwise.

Ann_BBO
08-08-2007, 03:41 AM
Anyway thanks to u, xld

Regrads
Ann

Charlize
08-08-2007, 05:43 AM
Not sure if it's the thing that you're after. But this one colors the line when processed (doubleclick). Need to build some code to know if the file is processed after you have closed this file (write the filenames to a sheet that are processed and compare them or compare the dir() statement with a value in a sheet and if no match found, load the filelink otherwise skip it).

SamT
08-08-2007, 01:41 PM
From my understanding of Excel-97, it would not be possible.


The three possible attributes of a Listbox that might apply are Text, Font, and ForeColor. Text applies to the character values, ie, abc; Font applies to the Font Face and ForeColor effects all the text in the list at the same time.

It is possible to remove the analyzed items and place them in another ListBox.

SamT

Ann_BBO
08-08-2007, 07:23 PM
Thanks for SamT!!
You give the great idea to me
I will try to write the vba to put the analyzed filelist(s) into the another listbox.

Thanks