473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Cannot Refer to an Instance member... Addhandler Issue

OK,

The problem isn't with Addhandler, it's with my
understanding of Shared...

I add a handler like this:
AddHandler ct.ColumnChanged, New _
DataColumnChangeEventHandler(AddressOf OnColumnChanged)
from within a Private Sub.

My handler is defined as:
Private Shared Sub OnColumnChanged(ByVal sender As _
Object, ByVal args As DataColumnChangeEventArgs)

When I attempt to set the state of a button in my form
using the
syntax "<squiggle>me.btnUpdate<squiggle>.Enabled = True"

I receive this error:
Cannot refer to an instance member from within a shared
member initializer without an explicit instance of the
class.

Isn't the button on my form an explicit instance of a
class?

Am I trying to do something that doesn't make sense?
Should I be reading up on Object references?

I sure would appreciate some insights. While I'm out here
I'll try to answer a couple of questions myself.

Thanks,

John

Nov 20 '05 #1
2 1475
"john" <jo*********@whizkidcomputing.cm> schrieb
OK,

The problem isn't with Addhandler, it's with my
understanding of Shared...

I add a handler like this:
AddHandler ct.ColumnChanged, New _
DataColumnChangeEventHandler(AddressOf OnColumnChanged)
from within a Private Sub.

My handler is defined as:
Private Shared Sub OnColumnChanged(ByVal sender As _
Object, ByVal args As DataColumnChangeEventArgs)

When I attempt to set the state of a button in my form
using the
syntax "<squiggle>me.btnUpdate<squiggle>.Enabled = True"

I receive this error:
Cannot refer to an instance member from within a shared
member initializer without an explicit instance of the
class.

Isn't the button on my form an explicit instance of a
class?

Am I trying to do something that doesn't make sense?
Should I be reading up on Object references?

I sure would appreciate some insights. While I'm out here
I'll try to answer a couple of questions myself.

Which instance of the Form should be accessed in the shared sub? Maybe there
is none, one or there are multiple instances.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "john" <jo*********@whizkidcomputing.cm> scripsit:
The problem isn't with Addhandler, it's with my
understanding of Shared...

I add a handler like this:
AddHandler ct.ColumnChanged, New _
DataColumnChangeEventHandler(AddressOf OnColumnChanged)
from within a Private Sub.

My handler is defined as:
Private Shared Sub OnColumnChanged(ByVal sender As _
Object, ByVal args As DataColumnChangeEventArgs)

When I attempt to set the state of a button in my form
using the
syntax "<squiggle>me.btnUpdate<squiggle>.Enabled = True"

I receive this error:
Cannot refer to an instance member from within a shared
member initializer without an explicit instance of the
class.

Isn't the button on my form an explicit instance of a
class?

Am I trying to do something that doesn't make sense?
Should I be reading up on Object references?

I sure would appreciate some insights. While I'm out here
I'll try to answer a couple of questions myself.


What's your intention of declaring the handler as 'Shared'? The
'Shared' keyword means that the procedure is shared between all
instances of the form class in your case. The control/class you add the
handler to is an instance object, it's not shared between all instances
of the form/class.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Drew | last post by:
I am trying to use Bulk Insert for a user that is not sysadmin. I have already set up the user as a member of "bulkadmin". When I run the following script: DECLARE @SQL VARCHAR(1000) CREATE...
9
by: Rob Mayo | last post by:
I have a bunch of XSD files in my assembly as embedded content that are read out via reflection and streams. My app creates the XML on the fly, and I want to validate it using the schema files...
5
by: kuvpatel | last post by:
Hi I want to refer a class called LogEvent, and use one of its methods called WriteMessage without actually having to create an instance of Logevent. I have tried using the word sealed with...
8
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - ...
4
by: Ryan | last post by:
I have some custom forms that contain their own properties and I call them as such: Dim myDialog As New myDialogForm myDialog.mID = 1 ' sets the custom property mID to 1...
0
by: Larry Lard | last post by:
This came out of a thread explaining to "BK" about error BC42025 ("Access of shared member through an instance; qualifying expression will not be evaluated"); Frans Clasener then came up with...
2
by: cody | last post by:
class Test { IList list = new ArrayList(); MyCollection list2 = new MyCollection (list); } Leads to this error. I know I could initialize them in the ctor but I'm asking myself where this...
6
by: Savante | last post by:
I have been writing a datalogging application. It reads in double's into a database. I want to be able to click on a row in a database (holds name of variable and also current value of variable)...
13
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.