How to use "Sender" in click-events?

Discussion in 'Questions (Windows Mobile)' started by Stellaferox, Feb 19, 2008.

  1. Stellaferox

    Stellaferox Active Member Licensed User

    Hi,

    I've got a program with a bunch of images on which can be clicked. All subs have the same structure with just one difference: the name of the image. Can this be reduced to ONE sub in which the Sender-feature is used?
    example:

    Code:
    Sub [COLOR="Red"]Img1_Click  'img2_click, img3_click etc[/COLOR]
      If Deck(SuitNr) = 0 Then
        CheckCard
        [COLOR=
    "Red"]img1.Image = Cards.RetrieveImage 'img2, img3 etc[/COLOR]
        If CardNr = Target Then 
          frmCards.Close
          ShowCards
        
    End If
      
    End If
    End Sub
    thnx
    Marc
     
  2. specci48

    specci48 Well-Known Member Licensed User

    Hi Stellaferox,

    first add an identical event to all your images like
    Code:
    AddEvent("img1", Click, "Image_Click")
    AddEvent(
    "img2", Click, "Image_Click")
    AddEvent(
    "img3", Click, "Image_Click")
    Then you can
    Code:
    Sub Imgage_Click
      
    If Deck(SuitNr) = 0 Then
        CheckCard
        
    Control(Sender).Image = Cards.RetrieveImage
        
    If CardNr = Target Then 
          frmCards.Close
          ShowCards
        
    End If
      
    End If
    End Sub

    specci48
     
  3. Stellaferox

    Stellaferox Active Member Licensed User

    Hi Specci48,

    You've been most helpfull...
    Thanks very much!!!
    Marc
     
  4. specci48

    specci48 Well-Known Member Licensed User

    That's the aim of all users of this forum... :sign0060:

    specci48
     
  5. Erel

    Erel Administrator Staff Member Licensed User

Loading...