By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,986 Members | 1,944 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,986 IT Pros & Developers. It's quick & easy.

How Set A Class Property To True - AddHandler - Button Click ?

P: 4
Vb.net – VStudio 2010 – Win 7

FORM Class Project Named ‘Notify’
With Reference to ZonesLib - Successful Build

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class Alarms
  3.  
  4. Private Sub myAlarms_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load     
  5. End Sub
  6.  
  7. ‘In code just below am trying to Set iSkip Property in ZonesLib.TimerProc to True using AddHandler event
  8. ‘The code runs but nothing happens… missing args?? something stupidly simple in my AddHandler code or event handler code ??
  9.  
  10. Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  11.    AddHandler Button1.Click, AddressOf ZonesLib.TimerProc.SetSkip
  12.    Me.Close()
  13. End Sub
  14.  
  15. End Class
  16.  
  17.  

Standard Class Project Named ‘ZonesLib’ - Successful Build

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class TimerProc
  3.  
  4.      Public Shared Sub SetSkip(sender As System.Object, e As System.EventArgs)
  5.          iSkip = True
  6.          MsgBox("Skip")
  7.     End Sub
  8.  
  9.     Private Shared _iSkip As Boolean = False
  10.     Public Shared Property iSkip() As Boolean
  11.         Get
  12.             iSkip = _iSkip
  13.         End Get
  14.         Set(ByVal value As Boolean)
  15.             _iSkip = value
  16.         End Set
  17.     End Property
  18.  
  19. End Class
  20.  
  21.  
Attached Files
File Type: docx AddHandlerSyntaxQuestionInWordFormat.docx (15.2 KB, 304 views)
Mar 18 '15 #1

✓ answered by CJames

OK... Doh !!...

I moved the AddHandler line of code to handle the Button1.click event into the form's Load event instead of having it in its own Button1.click Sub with an immediate Me.Close line of code...

Since how could an addhandler 'listen' for a click event with the Form already closed...

Works fine Now... Move along... nothin' to see or learn here.

:o)

CJ

Share this Question
Share on Google+
1 Reply


P: 4
OK... Doh !!...

I moved the AddHandler line of code to handle the Button1.click event into the form's Load event instead of having it in its own Button1.click Sub with an immediate Me.Close line of code...

Since how could an addhandler 'listen' for a click event with the Form already closed...

Works fine Now... Move along... nothin' to see or learn here.

:o)

CJ
Mar 19 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.