[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Listview Question

Posted on 2002-04-05
Medium Priority
Last Modified: 2012-05-04
Hello Experts:

I have a listview that displays invoices.  I want to change the color of the font in the row based on the status of the invoice.

If the invoice has been paid, it should be red
If the invoice has been paid late, it should be yellow
If the invoice is current, it should be black.

I know you use the following syntax to change the forecolor of the item:

InvoiceList.ListItems(Counter).ForeColor = vbRed
lv.ListSubItems(1).ForeColor = vbRed
lv.ListSubItems(2).ForeColor = vbRed

But I don't want to do this for every different color, so Id like to put the color to be displayed in a variable and do the following:

InvoiceList.ListItems(Counter).ForeColor = ColorSelect
lv.ListSubItems(1).ForeColor = ColorSelect
lv.ListSubItems(2).ForeColor = ColorSelect

And use a select statement to determine the status of the invoice.

Question is, what variable type would I define ColorSelect as so it can hold values like vbred, vbblue, etc.?


Question by:escheider
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

RichW earned 40 total points
ID: 6921225
You might be better off using the QBColor(color) method.

0 Black 8 Gray
1 Blue 9 Light Blue
2 Green 10 Light Green
3 Cyan 11 Light Cyan
4 Red 12 Light Red
5 Magenta 13 Light Magenta
6 Yellow 14 Light Yellow
7 White 15 Bright White

To change a color property to red you could try:

Dim lngColor as Long
lngColor = 4
Listview.BackColor = QBColor(lngColor)


Expert Comment

ID: 6921252
Dim ColorSet as long


dim ColorSet(2) as long

Author Comment

ID: 6921277
Thanks Rich...I love quick and easy answers..

I appreciate everyone's input, thanks for taking time out of your busy day to help...

Expert Comment

ID: 6921925
Thanks escheider.  Glad I could help.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question