473,322 Members | 1,496 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.

Strangest VB Quirk I've Seen

I was looking at one of the Microsoft VB.net sample apps and I
couldn't believe what I was seeing: apparently in VB you can declare
an event with the name X and refer to it in code with the name
XEvent.

I right-clicked on the event reference in code (XEvent) and of course
the IDE didn't know what to make of it, but the event was declared
with the name X - this rubbish actually compiled!!!

What gives !!?? I thought I had seen some horrible stuff allowed by
VB, but this takes the cake!
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
5 881
Hi NedMan,

Can you please send some code for me it is totaly unclear what you are
telling?

Cor
Nov 20 '05 #2
I'l clarify.

Public Event X()
.. . . . In Code.

XEvent() is recognised
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi NedMan,

Can you please send some code for me it is totaly unclear what you are
telling?

Cor

Nov 20 '05 #3
* th***********@yahoo-dot-ca.no-spam.invalid (TheNedMan) scripsit:
I was looking at one of the Microsoft VB.net sample apps and I
couldn't believe what I was seeing: apparently in VB you can declare
an event with the name X and refer to it in code with the name
XEvent.
This is "by design". An event is basically a mask for a delegate. When
declaring an event, a hidden delegate type will be created. This
delegate tyoe accepts methods with the same signature as the event. In
addition to that, a hidden variable of this type will be created. The
name of this variable consists of the event's name with 'Event'
appended.
What gives !!?? I thought I had seen some horrible stuff allowed by
VB, but this takes the cake!


It's all OK...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
No - that's not it - portions of the example are listed below - note
the delegate was explicitly declared:

Public Delegate Sub ProductsTDSRowChangeEventHandler(ByVal sender As
Object, ByVal e As ProductsTDSRowChangeEvent)

Public Event ProductsTDSRowChanged As
ProductsTDSRowChangeEventHandler

Protected Overrides Sub OnRowChanged(ByVal e As
DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.ProductsTDSRowChangedEvent) Is Nothing) Then
RaiseEvent ProductsTDSRowChanged(Me, New
ProductsTDSRowChangeEvent(CType(e.Row,ProductsTDSR ow), e.Action))
End If
End Sub
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #5
From the Microsoft sample "How-To Create an Offline Application":

Public Delegate Sub CustomersRowChangeEventHandler(ByVal sender As
Object, ByVal e As CustomersRowChangeEvent)
Public Event CustomersRowChanged As CustomersRowChangeEventHandler

Protected Overrides Sub OnRowChanged(ByVal e As
DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.CustomersRowChangedEvent) Is Nothing) Then

RaiseEvent CustomersRowChanged(Me, New
CustomersRowChangeEvent(CType(e.Row,CustomersRow), e.Action))
End If
End Sub

CustomersRowChangedEvent is not defined anywhere - the IDE can't
navigate to its definition - when hovering over
it, the IDE says it's:
Private Dim CustomersRowChangedEvent As
HowTo.CustomersDataSet.CustomersRowChangeEventHand ler

This is driving me insane - Herfried K. Wagner says that a hidden
delegate is created, but that is not
happening here since the CustomersRowChangeEventHandler delegate is
explicitly created. So why the need
for the hidden variable CustomersRowChangedEvent?

Even more confusing is why would there be any need to refer to this
(unneeded) hidden variable??
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #6

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

Similar topics

1
by: Peter Billam | last post by:
Greetings. This problem arises in the context of the CPAN module Crypt::Tea ... It works with IE, Mozilla, Netscape, Firefox, IE and Opera, but if you check out...
5
by: Christopher Benson-Manica | last post by:
Why does ''.split(',') yield an array with length 1 rather than an array with length 0? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
23
by: Mark Dickinson | last post by:
I have a simple 192-line Python script that begins with the line: dummy0 = 47 The script runs in less than 2.5 seconds. The variable dummy0 is never referenced again, directly or indirectly,...
3
by: Not Me | last post by:
Hi, This happened a while back but never since, until now. When in the sql view of MS Access (2002) and I try to edit the text, quite often random characters get inserted, and other characters...
26
by: Jannick | last post by:
Hi I have: unsigned int myvalue=0; unsigned char mytest=0; mytest=0x34; myvalue = mytest<<24; Then myvalue gets the value 0x1A000000!!!!! How is this possible? Should'nt it be 0x34000000???
4
by: mux | last post by:
Hi I found out that the following piece of code throws an error. 1 #include "stdio.h" 2 3 int main() 4 { 5 int a,b; 6 a= 10;
2
by: paul.mason | last post by:
I was wondering if anyone else had come across this "feature" of .NET and if they had any idea what might be causing it. I've been writing my first C# Windows application (so if there's anything...
7
by: David Lowndes | last post by:
The following example illustrates something that's taken me a while to suss out (debugging someone else's code :( )... The crux is that the code compiles cleanly at W4, and the issue is that I'm...
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...
0
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...
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: 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...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
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.