Solved

determine numbers in a 80 number msflexgrid

Posted on 2014-01-17
8
230 Views
Last Modified: 2014-01-18
I am saving an array of upto 10 numbers to a file the numbers in the array are saved
based on the .cellforecolor in a 80 number msflexgrid
 I am trying to deterime how to set the cell images based on the numbers in an array
the array is declared like this
Dim mMarkedNumber(1 To 10)  As Integer
the array holds as many as 10 numbers
example array
1 = 1
2 = 5
3 = 10
4 = 21
5 = 26
6 = 46
7 = 50
8 = 71
9 = 76
10 = 80

columns = 0 To 9
 rows = 0 To 7
The problem I am having is determing which number in the msflexgrid matches the number in the array.
Example 4th dimintion = 21
how can i write code to determine which number in the 80 number grid is number 21
flexCleo.row = 2
flexCleo.col = 0
Set .CellPicture = imgSelNotHit
this will select number 21

How can i write this?
80-number-grid.jpg
0
Comment
Question by:isnoend2001
  • 4
  • 4
8 Comments
 

Author Comment

by:isnoend2001
ID: 39790668
got this answer from another forum and it seems to be close:

Given that your flex grid rows and columns start at zero then
Row = value \ 10
column = (value - 1) Mod 10

e.g. If value = 21 then row = 21 \ 10 = 2, column = (21 - 1) mod 10 = 0
So you'd find 21 in row 2, column 0 in the grid.
after testing the code is close except the last column is off by 1 row
mMarkedNumber(1) = 1
mMarkedNumber(2) = 5
mMarkedNumber(3) = 10 'selects 20
mMarkedNumber(4) = 21
mMarkedNumber(5) = 26
mMarkedNumber(6) = 46
mMarkedNumber(7) = 50 'selects 60
mMarkedNumber(8) = 71
mMarkedNumber(9) = 76
mMarkedNumber(10) = 80 'invalid row value
'seems the last column row value is 1 number too many

This modification seems to fix problem, but not sure if this is the correct way
If Right(nu, 1) = 0 Then
.Row = nu \ 10 - 1 ' minus 1 if the last column
.Col = (nu - 1) Mod 10
Set .CellPicture = imgSelNotHit
Else
.Row = nu \ 10
.Col = (nu - 1) Mod 10
Set .CellPicture = imgSelNotHit
End If
0
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39790785
The following will give you the cell and row coordinates of any of your numbers. In this example we are looking for the number 21.

    Dim intRow As Integer
    Dim intcol As Integer
    
    Const TEST = 21
    
    intRow = (TEST - 1) \ 10
    
    intcol = TEST Mod 10 - 1
    If intcol = -1 Then
        intcol = 9
    End If
    MsgBox "Number is in row " & intRow & " column " & intcol

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39790822
Thanks Martinliss
Glad you are there or here whatever the case may be
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:Martin Liss
ID: 39790830
Was in Peru for a while but I'm back... and you're welcome/
0
 

Author Comment

by:isnoend2001
ID: 39790845
Glad you are back, was hoping you would answer a couple questions i asked recently.
I think some of the experts there assume i know more than i do and their answers are difficult
to understand
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39790891
I think that most of the better experts will answer followup questions if you don't understand parts of their code. I know I will:)
0
 

Author Comment

by:isnoend2001
ID: 39790923
I think the difference is most of your answers do not need followup and i am not looking for email buddies
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 39790938
I'm not sure what email has to do with it but if you ever have a question about any code that I supply then please just ask.
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

Suggested Solutions

Title # Comments Views Activity
VB 6.0 printer how to align 6 71
Crystal reports - Formula Field code need assistance with code 17 90
Excel Automation VBA 19 102
Error with a code discussed on this page 5 38
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

713 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