Solved

Flex Grid and Images for Cliff

Posted on 1998-06-17
1
231 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
1 Comment
 
LVL 6

Accepted Solution

by:
clifABB earned 40 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now