Solved

Flex Grid and Images for Cliff

Posted on 1998-06-17
1
237 Views
Last Modified: 2008-02-20
Cliff,

Your code seemed to work but I need it on columns 3, 4, and 5.  I tried to change the col nums in the code but with my limited ability can't seem to change the right numbers to make your code work on columns 3, 4, and 5.  Can you help for my remaining points?

Warren
0
Comment
Question by:clarwc
[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
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
clifABB earned 40 total points
ID: 1463553
Using my previous example, I'll change the column number to a variable, then you can just change the value of the variable as you need:

  Dim nCnt1     As Integer
  Dim sPicFile  As String
  Dim nColNum   As Integer

  nColNum = 3 'or 4 or 5
   
  For nCnt1 = 1 To MSFlexGrid1.Rows - 1
    Select Case MSFlexGrid1.TextMatrix(nCnt1, nColNum)
      Case "Red"
        sPicFile = "c:\temp\Redball.gif"
      Case "Green"
        sPicFile = "c:\temp\Greenball.gif"
      Case "Blue"
        sPicFile = "c:\temp\Blueball.gif"
      Case Else
        sPicFile = "" 
    End Select
    If sPicFile <> "" Then
      MSFlexGrid1.Col = nColNum
      MSFlexGrid1.Row = nCnt1
      Set MSFlexGrid1.CellPicture = LoadPicture(sPicFile)
      MSFlexGrid1.TextMatrix(nCnt1, nColNum) = "" 
    End If
  Next nCnt1


Or better yet, if you are going to always use 3, 4, and 5, we can make a loop:
  Dim nCnt1     As Integer
  Dim sPicFile  As String
  Dim nColNum   As Integer

  For nCnt1 = 1 To MSFlexGrid1.Rows - 1
    For nColNum = 3 To 5
      Select Case MSFlexGrid1.TextMatrix(nCnt1, nColNum)
        Case "Red"
          sPicFile = "c:\temp\Redball.gif"
        Case "Green"
          sPicFile = "c:\temp\Greenball.gif"
        Case "Blue"
          sPicFile = "c:\temp\Blueball.gif"
        Case Else
          sPicFile = "" 
      End Select
      If sPicFile <> "" Then
        MSFlexGrid1.Col = nColNum
        MSFlexGrid1.Row = nCnt1
        Set MSFlexGrid1.CellPicture = LoadPicture(sPicFile)
        MSFlexGrid1.TextMatrix(nCnt1, nColNum) = "" 
      End If
    Next nColNum
  Next nCnt1

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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 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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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