Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Could someone please tell me what i am doing wrong? I've based this from an example from a book - which doesnt work either! Good book huh?

 

       Dim cls2Killed As ClsProcess
       cls2Killed = New ClsProcess

       cls2Killed.blah = 10
       MsgBox(cls2Killed.blah)

 

Public Class ClsProcess
   Inherits EventArgs

   Private testint As Integer

   Public Property blah() As Integer
       Get
           blah = testint
           MsgBox("retrieving a value " + Str(blah))
       End Get
       Set(ByVal Value As Integer)
           MsgBox("setting a value " + Str(blah))
       End Set
   End Property

End Class

 

Thanks

Posted (edited)

Thanks PD, i double checked the book after i read this and it is definately wrong. Its not just an oversight on my behalf.

 

When running the program i get the following msgboxes:

*retrieving a value 10

*setting a value 10

*set

*retrieving a value 10

*10

 

When debugging i've added a watch for cls2Killed.blah and i get "error: cannot obtain value". Firstly why does it 'get' the value before setting it? Secondly is the error displayed in the watch and error for the watch, or an actual error in my program? It displays the 10 value correctly.

 

 

   Private testint As Integer

   Public Property blah() As Integer
       Get
           blah = testint
           MsgBox("in blah and retrieving a value" + Str(blah))
       End Get
       Set(ByVal Value As Integer)
           testint = Value
           MsgBox("in blah and setting a value" + Str(blah))
       End Set
   End Property

 

       Dim cls2Killed As ClsProcess
       cls2Killed = New ClsProcess(5, 6)

       cls2Killed.blah = 10
       MsgBox("set")
       MsgBox(cls2Killed.blah)

 

Thanks

 

PS i think i need another book :eek:

Edited by Jay1b

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...