[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Passing control name to fucntion!?

Hi all,

 I'm wondering if it's posible to pass the name of the control to a function:
eg: I have a 3 Msflexgrid's - Msflexgrid1(1 rows, 3cols),Msflexgrid2(4 rows, 3cols),Msflexgrid3(2 rows, 3cols). When click on a button I'm calling a funtion which will do some calculation involving these 3 grids.
My question is, can I send the name of the controls (Msflexgrid1,2,3) and use them trhough the function?

thanks
0
rod69
Asked:
rod69
  • 2
  • 2
1 Solution
 
Erick37Commented:
In your form, use this

Call MyFunction(Me.MsFlexGrid1)


'And in your module, your function is declared like this...

Public Function MyFunction(grid As MsFlexGrid)
   
    With grid
    .TextMatrix(...)
    'and so on
    End With

End Function
0
 
brianb99999Commented:
or

call MyFunction(me.myGrid)


Public function functionname(grid as control)
...

Brian.
0
 
Erick37Commented:
and

You can test for a specific name like this:

Public Function MyFunction(grid As MsFlexGrid)
   
    Select Case grid.Name

    Case "MsFlexGrid1"
        ...

    etc...
0
 
Mikal613Commented:
dan shouldnt  Callbyname be suffice
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now