473,379 Members | 1,252 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,379 software developers and data experts.

'Me' is valid only within an instance method.

Hi All,

I have a strange issue, and I am not sure if it is a error on my part, or a
visual studio bug.

I am using VS.Net 2003 Enterprise.

I have 2 event handlers as follows:

Public Shared Sub txtFace1_DoubleClick(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtFace1.DoubleClick
Dim SWin As New search
Caller = "Face1"
SWin.ShowDialog(Me)
End Sub

Private Sub txtFace2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtFace2.DoubleClick
Dim SWin As New search
Caller = "Face2"
SWin.ShowDialog(Me)
End Sub

However the first event handler gives me the following error:

C:\Documents and Settings\xxx\My Documents\Visual Studio Projects\Ware House
Control System\Forms\Form5.vb(884): 'Me' is valid only within an instance
method.

Yet the second event handler is fine and generates no warnings.

Does anyone know what this issue is?

Thanks

Nov 23 '05 #1
4 7155
"Materialised" <ma**********@privacy.net> schrieb:
Public Shared Sub txtFace1_DoubleClick(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtFace1.DoubleClick
[...]
C:\Documents and Settings\xxx\My Documents\Visual Studio Projects\Ware
House Control System\Forms\Form5.vb(884): 'Me' is valid only within an
instance method.


Remove the 'Shared' keyword.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 23 '05 #2
Materialised.

No it is not a bug.

Is there any reason that you make that first event "Shared" and that second
not. I cannot think about any situation. However if it is a shared part of
your program, than it cannot be the referce to *this* class, shared is
usable from all classes.

I hope this helps,

Cor
Nov 23 '05 #3

"Materialised" <ma**********@privacy.net> wrote in message
news:3u*************@individual.net...
Hi All,

I have a strange issue, and I am not sure if it is a error on my part, or
a visual studio bug.

I am using VS.Net 2003 Enterprise.

I have 2 event handlers as follows:

Public Shared Sub txtFace1_DoubleClick(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtFace1.DoubleClick
Dim SWin As New search
Caller = "Face1"
SWin.ShowDialog(Me)
End Sub

Private Sub txtFace2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtFace2.DoubleClick
Dim SWin As New search
Caller = "Face2"
SWin.ShowDialog(Me)
End Sub

However the first event handler gives me the following error:

C:\Documents and Settings\xxx\My Documents\Visual Studio Projects\Ware
House Control System\Forms\Form5.vb(884): 'Me' is valid only within an
instance method.

Yet the second event handler is fine and generates no warnings.

Does anyone know what this issue is?

Thanks


Thank you to those of you who replied.
Nov 23 '05 #4
Right, using the Shared keyword causes the thing to be created, you dont
need the "new" declaration to make an instance.

So it will complain if there is a mix of things created now, and things that
are not created until something creates them with 'new' at some later time,
there is no guarantee when those will exist. Kind of a logic error there.

If you declare something Shared, it is accessible by dot notation using the
Class name, right now. But the only solution appears in the use of
delegates.

Is this correct? Is there any easier way?

"Materialised" <ma**********@privacy.net> wrote in message
news:3u*************@individual.net...
Hi All,

I have a strange issue, and I am not sure if it is a error on my part, or a visual studio bug.

I am using VS.Net 2003 Enterprise.

I have 2 event handlers as follows:

Public Shared Sub txtFace1_DoubleClick(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtFace1.DoubleClick
Dim SWin As New search
Caller = "Face1"
SWin.ShowDialog(Me)
End Sub

Private Sub txtFace2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtFace2.DoubleClick
Dim SWin As New search
Caller = "Face2"
SWin.ShowDialog(Me)
End Sub

However the first event handler gives me the following error:

C:\Documents and Settings\xxx\My Documents\Visual Studio Projects\Ware House Control System\Forms\Form5.vb(884): 'Me' is valid only within an instance
method.

Yet the second event handler is fine and generates no warnings.

Does anyone know what this issue is?

Thanks

Nov 24 '05 #5

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

Similar topics

3
by: JIM.H. | last post by:
Hello, I have only one form with a listbox:lbFileContent, and I have this code in Public Class Form1. Public Shared Sub UploadFile(ByVal fileNamePath As String) Dim reader As StreamReader = New...
6
by: Martin | last post by:
I'd like to be able to get the name of an object instance from within a call to a method of that same object. Is this at all possible? The example below works by passing in the name of the object...
8
by: Anthony Williams | last post by:
Morning all, I'm having a wee problem with a project I'm working on at the moment. I'm leading my company into producing a website, based upon Web Standards, which will be created using XHTML...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
10
by: AC [MVP MCMS] | last post by:
How do you get the current instance of an executing assembly from within a static method? I'm trying to use the LicenseManager.Validate(type,instance) method and having trouble calling it from...
24
by: M O J O | last post by:
Hi, Instead of doing this.... Public Class Form1 Public Shared Sub CreateAndShow() Dim f As New Form1 f.Show() End Sub
4
by: Pieter | last post by:
Hi, Using VB.NET 2005: When you use a Me.MyFunction to a Shared Method, you het the error "'Me' is valid only within an instance method.". Which is normal. But: Which keyword can you use...
0
by: Wanxi | last post by:
Hi everyone, I am testing one of the example -> <UsingTheSerialPort> at VB101SamplesBCL2. But there are some error which i don't know how to edit. I found some post that having the same problem...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.