Can one item hold more events ?  
Author Message
Spider-link





PostPosted: Visual Basic Express Edition, Can one item hold more events ? Top

Can, lets say a button handle two events. I need this
Private sub btnStart () handles btnStart.MouseEnter
btnStart.Image = ("somewhere")
End Sub

Private Sub btnStart () handles btnStart.MouseLeave
btnStart.Image = ("somewhere")
End Sub




Visual Studio Express Editions29  
 
 
Frank Boyne





PostPosted: Visual Basic Express Edition, Can one item hold more events ? Top

Yes a function can be used to handle more than one event.  Just list all the events separated by commas after the 'handles' keyword

Private sub btnStart () handles btnStart.MouseEnter, btnStart.MouseLeave

Obviously the signature of the function has to match the signature of both the event's handlers.  For example, one function can't handle both MouseEnter and MouseDown because MouseEnter requires an EventHandler function while MouseDown requires a MouseEventHandler function.