[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
Solved

# changing msflexgrid row to a different color if the number displays negative.

Posted on 2004-10-21
Medium Priority
234 Views
Since I was able to display negative numbers in an msflexgrid,
I would also like to display it in red for that row. How to do that?

Part of the code I'd like to insert the code... to change row color if negative

With grdEquipData
'Check if "Cost" and "Qty" are available
If (Trim(.TextArray(.row * .Cols + 7)) <> "" And Trim(.TextArray(.row * .Cols + 3)) <> "") Then
'Total Cost = Unit Cost * Qty
.TextArray(.row * .Cols + 8) = FormatNumber((.TextArray(.row * .Cols + 3)) * Val((.TextArray(.row * .Cols + 7))), 2)
End If
end with
0
Question by:zachvaldez
[X]
###### 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

LVL 53

Accepted Solution

Dhaest earned 260 total points
ID: 12369982
With MSflexgrid there is no straight way to set color to a full row. You have to set color cell by cell. Lets say you have 5 columns and and want to set color of 4th row to yellow, then this is how you will do it:

For intLoop=0 to 4
With MSHFlexgrid1
.Row=4
.Col=intLoop
.CellBackColor=vbYellow
End With
Next
0

LVL 6

Assisted Solution

PePi earned 240 total points
ID: 12371719
try this

With grdEquipData
.Row = r            'set the row you want to change the color
for c = 0 to .Cols -1            'loops through all the columns in the row nd changes its color
.Col = c
.CellBackColor = vbRed
next c
End With

hope this helps
0

Author Comment

ID: 12373405
only when it is negative number though..
i'd like the row to display color red...
.TextArray(.row * .Cols + 8) = FormatNumber((.TextArray(.row * .Cols + 3)) * Val((.TextArray(.row * .Cols + 7))), 2)
0

## Featured Post

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
###### Suggested Courses
Course of the Month13 days, 9 hours left to enroll