VB6 multiple selections from msflexgrid to array with checks

Hi,

Our inhouse software covers invoice registration amongst other things. (Visual Basic 6)
Operational people enter their expected costs on a per file basis.
When the actual invoice arrives, the finance department registers the invoice in their part of the system, then matches the "expected costs" entered by the operational people to the actual invoice.

At the moment the finance users can only select one line at a time and the confirm.
I would like them to be able to match multiple lines in one go.
The selections are made from a msflexgrid.

To start with I created:
Private Type RowsToValidate
   DetID as long ' ID of the expected costs table
   RegNr as long ' The invoice registration number
   FlexRowNr as Byte ' Flex line nr ' Don't know if this is even necessary
End Type
Dim ValRows() as RowsToValidate 'Rows to confirm

When the user clicks on the flex to make the selection I would like:
A check to see if it has already been selected. If so remove it from the array (Deselect)
If it hasn't been selected I want to add it to the array.

Once the user has made all the selections they want, they will click on a button to do the confirmation (Validation)
This will be done by a function. For this to work i'll need to know how many values are in the array.
Can I use something like:
FOR i = 0 to max(Array) ????
or should I use the recordset count from the rs used to fill the flex in the first place???

As this is the first time I have worked with types, arrays and multiple selections on flexgrids, I am having a trouble getting my head around the logic needed and the steps involved.

Thanks in advance for any help you can offer.






LVL 2
DennisPostAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TreyHCommented:
Will the selections be contiguous or non-contiguous?
The MSHFlexGrid by design does not offer multiple non-contiguous cell selection. You would probably have to investigate a 3rd party control to do that.
0
DennisPostAuthor Commented:
Hi TreyH,

That's some bad news as they will be non-contiguous.
I just finished another sub to allow the users to validate all available "excpected costs". :

dim i as integer
    'Fill the array with values from the recordset
    i = 1
    rsInvLines.MoveFirst
    Do While rsInvLines.EOF = False
        ValRows(i).DetID = rsInvLines!DetID
        ValRows(i).RegNr = Me.txtNum
        i = i + 1
        rsInvLines.MoveNext
    Loop
   
    'Cycle through the array calling the function ValidateRows each time
    For i = 1 To intRSRows
        ValidateRows ValRows(i).DetID, ValRows(i).RegNr
    Next i

This will suffice,
but I would still like to realize my question.

I will try some of these EE checkbox in flexgrid answers.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21737329.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20803581.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_11819218.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20313081.html

I you have a better idea, please don't be shy about letting know about it. :-)


0
nirojexpertCommented:
denispost,

you can use hidden columns to store the state of selections
for example
'while loading data set the first column;s visibility to off, rest columns contain your data.
with grid
.column(0).width=0
end with

'when user click to make selection, you can do as
if .textmatrix(.row, 0) = "" then 'no selection so far
   .col = 1
   set .cellPicture = loadPicture("C:\selected.gif")
 .text = 1
else
   .col = 1
   set .cellPicture = loadPicture("C:\notselected.gif")
 .text = 0
end if


'now to find the selected ones
selID = ""
with grid
  for i= 0 to .rows-1
     if .textmatrix(i,0) = 1 'this is a selected row
      if selID ="" then
               selID = .textMatrix(.row, 0)
      else
               selID = selID & .textmatrix(.row, 0)
      end if
   end if
  next i
end with
  idArray = split(selID, ",")


'so there is no restriction in how the user will make the selecetion
but the user has to click on the row to make the selection
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DennisPostAuthor Commented:
Thanks Nirojexpert,

I am a little swamped with other higher priority work at the moment. I will try this out as soon as I can.

A few questions about your code though.
Where can I get these .gif files?
I assume SellID is just an integer value.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right?
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)?

Thanks for your help!
0
nirojexpertCommented:
A few questions about your code though.
Where can I get these .gif files? it can be any. instead of c:\ make a folder "images " where exe is built and then use the app.path & "\images\selected.gif"

I assume SellID is just an integer value. you put the ID of the record that will identify the record.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right? . highlighting the whole row will depend on the property of grid.
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)? you will probably need to modify the function such that it can accept the whole array like ValidDateRows(Rows() ), etc
upload your code blocks, i will be able to help further
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.