Results 1 to 2 of 2

Thread: Passing A Control

  1. #1

    Thread Starter
    Addicted Member overhill's Avatar
    Join Date
    Mar 2000
    Location
    KS, United States
    Posts
    181

    Passing A Control

    I know what I want to do, but I don't know the code to do it. I have a function that populates a MSFlexGrid control with data. What I want to do each time that I call the Populate(x as MSFlexGrid) function is to pass it the proper flexgrid to populate.

    As you might be able to tell, I have the code already built into the function, but don't know how to pass it a flexgrid.

    I tried Populate(my_control) but that didn't seem to work. What do I need to do to call this function?

    Thanks!

  2. #2
    PowerPoster beachbum's Avatar
    Join Date
    Jul 2001
    Location
    Wollongong, NSW, Australia
    Posts
    2,274
    Hi
    Something like this... I have 2 command buttons on a form (command1.. command2) and 2 flexgrids (msflexgrid1 and msflexgrid2)
    VB Code:
    1. Private Sub Command1_Click()
    2.     Populate MSFlexGrid1
    3. End Sub
    4.  
    5. Private Sub Command2_Click()
    6.     Populate MSFlexGrid2
    7. End Sub
    8.  
    9. Private Sub Populate(MyGrid As MSFlexGrid)
    10.     With MyGrid
    11.         .AddItem "blah"
    12.         .AddItem "blah"
    13.     End With
    14. End Sub
    Also, if all the grids are in a control array (ie same name, different indexes) u only need to pass the index number if the populate sub is in the same form...eg
    VB Code:
    1. Private Sub Command1_Click()
    2.     Populate 1
    3. End Sub
    4.  
    5. Private Sub Command2_Click()
    6.     Populate 2
    7. End Sub
    8.  
    9. Private Sub Populate(GridNum as Integer)
    10.     With MyGrid(GridNum)
    11.         .AddItem "blah"
    12.         .AddItem "blah"
    13.     End With
    14. End Sub
    Regards
    Stuart
    Stuart Laidlaw
    Brightspark Financial Software
    http://www.gstsmartbook.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width