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

this pointer

kd
Hi All,

In vb.net. why can't a object be accessed within its event handler, uisng
'this' pointer?

Are there any alternatives to using 'this'?

kd
Nov 21 '05 #1
5 2079
"kd" <kd@discussions.microsoft.com> schrieb:
In vb.net. why can't a object be accessed within its event handler, uisng
'this' pointer?


Use 'Me' instead of 'this'.

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

Nov 21 '05 #2
kd

Me - refers to the form name and not the current object name.

kd

"Herfried K. Wagner [MVP]" wrote:
"kd" <kd@discussions.microsoft.com> schrieb:
In vb.net. why can't a object be accessed within its event handler, uisng
'this' pointer?


Use 'Me' instead of 'this'.

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

Nov 21 '05 #3
Hi,

Me refers to the current object. Which some times is a form. It
is the same as the c++ and c# this statement.

http://msdn.microsoft.com/library/de...ml/vakeyme.asp

Ken
---------------
"kd" <kd@discussions.microsoft.com> wrote in message
news:4A**********************************@microsof t.com...

Me - refers to the form name and not the current object name.

kd

"Herfried K. Wagner [MVP]" wrote:
"kd" <kd@discussions.microsoft.com> schrieb:
In vb.net. why can't a object be accessed within its event handler,
uisng
'this' pointer?


Use 'Me' instead of 'this'.

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

Nov 21 '05 #4
"kd" <kd@discussions.microsoft.com> schrieb:
Me - refers to the form name and not the current object name.


'Me' does exactly the same what 'this' does in C++, Java, and C#. Inside an
event handler you can get a reference to the control raising the event in
the value passed to the handler's 'sender' parameter:

\\\
Public Sub Button1_Click(...)...
Dim SourceControl As Button = DirectCast(sender, Button)
SourceControl.Enabled = False
...
End Sub
///

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

Nov 21 '05 #5
KD,

"Me" is the same as in C# "this". It is used in the class not in the
object.

In javascript it is often used as a passed reference to an object, that kind
of "this" you can use in VBNET in the same way as you do it in javascript,
something as

\\\\
dim dt as datatable = new datatable()
dt.columns.Add("hello")
dt.rows.Add(dt)

function mysub(byval this as datatable)
return this.NewRow
end function.
///

I hope this helps

Cor
Nov 21 '05 #6

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

Similar topics

1
by: Steven Wong | last post by:
hi, I've got a pthreaded app, which seg faults. Taking a look at the stack in gdb I notice the "this" pointer gets nulled in the stackframe where the seg fault occurs. Say its in an object,...
2
by: stub | last post by:
Some questions about "this" pointer: 1. To make an assignment function, Stribg &String::operator=(const String &other) { ... return *this; }
5
by: Rasti | last post by:
Hello, I am trying to translate a C++ script to Java. Are there any differences between the C++ this-pointer and the Java this-pointer? Thank you
4
by: tuko | last post by:
Hello everyone. At the following snippet, at the commented line the pointer is valid? I mean the object bar is not constructed yet. So after the contruction of the bar object, the list...
3
by: Eric Chaves | last post by:
Hi fellows, According to the C# language specification (10.5.3), Every virtual method has a "most derived implementation" determined by a 3-step rule. If I invoke the virtual method from a normal...
9
by: mailtogops | last post by:
Hi, I have this question in mind for many years.. C++ class provides encapsulation which encapsulate its members and member function. class Experiment { private:
0
by: thokadess | last post by:
Hi, Can anyone tell me,whether 'this' pointer is simple pointer to a perticular object or a const pointer to perticular object? Thanks in advance..
3
by: john | last post by:
Hey, I know we use the pointer this to obtain a class object or class member data. I don't follow the reason for example this code. I'am quite confused assingment operator const B...
8
by: amirr | last post by:
Guys, As you know static member functions do not have a this pointer. so instead, what shall i do? for example ... consider I want to call Code: ( text ) 1.
4
by: srini4vasan | last post by:
Can we delete 'this' pointer in C++. If so how can we delete this pointer? If not why?
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.