Solved

Flex Grid and Images for Cliff

Posted on 1998-06-17
1
236 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

739 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