Results 1 to 6 of 6

Thread: How to implement events in - _and_ outside of - a usercontrol array?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2017
    Location
    The Netherlands
    Posts
    42

    How to implement events in - _and_ outside of - a usercontrol array?

    Hi everyone,

    In a VB6 application I have to replace every ancient Sheridan SSRibbon control by a usercontrol "NewSSRibbon". The main form contains both SSRibbons in a control array and "stand alone" SSRibbons with an empty Index property.
    I have to implement the Click event in NewSSRibbon so that both handler signatures Sub btnNewSSRibbon1_Click() and Sub btnNewSSRibbon2_Click(Index As Integer) work.

    Declaring something like Public Event Click() next to Public Event Click(Index As Integer) obviously causes a compile error. "Optional Index As Integer" is not allowed.
    In addition, if this problem can be solved: how do I provide the correct Index? In Public Event Click(Index As Integer), Index is merely a placeholder. It doesn't refer to anything, which doesn't look right to me.
    And what would the RaiseEvent Click - statements look llike?

    How do I go about it?
    Thanks in advance!

    Cooz

  2. #2
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    462

    Re: How to implement events in - _and_ outside of - a usercontrol array?

    double post
    Last edited by DllHell; Aug 21st, 2018 at 11:03 AM.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    462

    Re: How to implement events in - _and_ outside of - a usercontrol array?

    Quote Originally Posted by Cooz View Post
    "Optional Index As Integer" is not allowed.
    remove the optional and it will work

    Code:
    Event Click(index As Integer)
    to raise it, call it in your user control:

    Code:
    RaiseEvent Click(idx)

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to implement events in - _and_ outside of - a usercontrol array?

    The Index gets implemented by the plumbing that underlies the control array mechanism. You don't need to do anything with it within the UserControl.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to implement events in - _and_ outside of - a usercontrol array?

    To piggyback on dilettante's reply.

    Don't include the Index parameter. When you have 1 instance of your control, the form hosting it will show this event:
    btnNewSSRibbon2_Click()

    If you change the control's Index property on the its hosting form, to a numeric value, then when you look at the event in the form:
    btnNewSSRibbon2_Click(Index As Integer)
    Last edited by LaVolpe; Aug 21st, 2018 at 04:37 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Member
    Join Date
    May 2017
    Location
    The Netherlands
    Posts
    42

    Re: How to implement events in - _and_ outside of - a usercontrol array?

    Hi all,

    Indeed - I was making a bit of a fuss here; it is far simpler than I expected. Got it working now. Thanks!
    Kind regards,

    Cooz

Tags for this Thread

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