473,791 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Overloading of the unary ++ operator in VB.net

Overloading of the unary ++ operator in vb.net is not working. It show error:
Operator declaration must be one of: +, -, *, \, /, ^, &, Like, Mod, And,
Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType, IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change developing
language to C#? Any suggestion?
Jun 27 '08 #1
15 2018
On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.comwrote:
Overloading of the unary ++ operator in vb.net is not working. It show error:
Operator declaration must be one of: +, -, *, \, /, ^, &, Like, Mod, And,
Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType, IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change developing
language to C#? Any suggestion?
++ is not an operator in VB.NET. As the error says, it must be one of
the listed operators.

--
Tom Shelton
Jun 27 '08 #2
"VB Developer" <VB*********@di scussions.micro soft.comschrieb
Overloading of the unary ++ operator in vb.net is not working. It
show error: Operator declaration must be one of: +, -, *, \, /, ^,
&, Like, Mod, And, Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType,
IsTrue, IsFalse.

Is there any way can to get rid of this error?
Yes, don't use "++". "++" is not a valid operator; but not only with
overloading. It does not exist.
C# is working fine for overloading ++, and do I need to change
developing language to C#?
You can't. You are VB Developer.
Armin

Jun 27 '08 #3
Tom Shelton wrote:
On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.com>
wrote:
>Overloading of the unary ++ operator in vb.net is not working. It
show error: Operator declaration must be one of: +, -, *, \, /, ^,
&, Like, Mod, And, Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType,
IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change
developing language to C#? Any suggestion?

++ is not an operator in VB.NET. As the error says, it must be one of
the listed operators.
Or one of +=, *=, &= and so on, which the help/error message seems to miss
out.

Andrew
Jun 27 '08 #4
On 2008-04-29, Andrew Morton <ak*@in-press.co.uk.inv alidwrote:
Tom Shelton wrote:
>On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.com>
wrote:
>>Overloading of the unary ++ operator in vb.net is not working. It
show error: Operator declaration must be one of: +, -, *, \, /, ^,
&, Like, Mod, And, Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType,
IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change
developing language to C#? Any suggestion?

++ is not an operator in VB.NET. As the error says, it must be one of
the listed operators.

Or one of +=, *=, &= and so on, which the help/error message seems to miss
out.

Andrew
hmmm, you are correct :) It does seem to leave those out.

--
Tom Shelton
Jun 27 '08 #5
"Andrew Morton" <ak*@in-press.co.uk.inv alida écrit dans le message de
groupe de discussion : 67************* @mid.individual .net...
Tom Shelton wrote:
>On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.com>
wrote:
>>Overloading of the unary ++ operator in vb.net is not working. It
show error: Operator declaration must be one of: +, -, *, \, /, ^,
&, Like, Mod, And, Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType,
IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change
developing language to C#? Any suggestion?

++ is not an operator in VB.NET. As the error says, it must be one of
the listed operators.

Or one of +=, *=, &= and so on, which the help/error message seems to
miss out.

Andrew
Similarly I would say that += etc... doesn't really exists. This is just a
shortcut notation... What if you try just + or whatever fit your needs ?

You may want to explain what you are trying to do...
--
Patrice

Jun 27 '08 #6
+= is not work too.

Code:
Public Shared Operator +=(ByVal bi As Integer) As Integer
............... .....

End Operator

Give the same error above.

Please check it before post yours.


"Tom Shelton" wrote:
On 2008-04-29, Andrew Morton <ak*@in-press.co.uk.inv alidwrote:
Tom Shelton wrote:
On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.com>
wrote:
Overloading of the unary ++ operator in vb.net is not working. It
show error: Operator declaration must be one of: +, -, *, \, /, ^,
&, Like, Mod, And, Or, Xor, Not, <<, >>, =, <>, <, <=, >, >=, CType,
IsTrue, IsFalse.

Is there any way can to get rid of this error?

C# is working fine for overloading ++, and do I need to change
developing language to C#? Any suggestion?

++ is not an operator in VB.NET. As the error says, it must be one of
the listed operators.
Or one of +=, *=, &= and so on, which the help/error message seems to miss
out.

Andrew

hmmm, you are correct :) It does seem to leave those out.

--
Tom Shelton
Jun 27 '08 #7
Patrice wrote:
"Andrew Morton" <akm@a écrit dans le message
>Or one of +=, *=, &= and so on, which the help/error message seems
to miss out.

Andrew

Similarly I would say that += etc... doesn't really exists. This is
just a shortcut notation... What if you try just + or whatever fit
your needs ?
You may want to explain what you are trying to do...
/I/'m trying to let the OP know there's no ++ operator in VB.NET... :-)

Andrew
Jun 27 '08 #8
This is just to port code and an attempt to avoid changing ++ ?

Depending on the reason for this port you could :
- compile the C# code into a DLL so that you can reuse this code without
even having to port
- also I've heard about translators being able to take source code in a
particular language and translate it to another language (try googling for
this)

Of course if you really want to this by hand you'll have anyway much bigger
changes than that...
--
Patrice

"VB Developer" <VB*********@di scussions.micro soft.coma écrit dans le
message de groupe de discussion :
DD************* *************** **...icrosof t.com...
>
I want to transfer C# code to VB.net code. I know now it is impossible at
some part and except you change original code such as ++ to +1.


Jun 27 '08 #9
On 2008-04-29, VB Developer <VB*********@di scussions.micro soft.comwrote:
>
I want to transfer C# code to VB.net code. I know now it is impossible at
some part and except you change original code such as ++ to +1.
Yep. VB.NET doesn't support pre/post increment/decrement operators.
The closest you get is:

b += 1

or

b -= 1

And that is just a shortcut for:

b = b + 1

or

b = b -1

One more reson to prefer C# :)

--
Tom Shelton
Jun 27 '08 #10

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

Similar topics

4
1780
by: PKH | last post by:
This is a part of an autopointer template i'm using. I originally had a Get() member that returned the pointer, but thought it would nice to be able to use the -> operator. The question is why does the following line work, and call cAP.m_pcPointer->Testing() ? cAP->Testing(); // ??? cAP-> returns a CTest*, so it looks to me like the line reads cAP.m_pcPointer <whitespace> Testing(), but it actually does
2
1360
by: Ook | last post by:
This is a few ways I've seen to overload operator+. I can understand that you would want to pass a reference to the function if you wanted to change some of the data elements of the class, but in the first example it's being passed as a constant. Is this done for performance purposes so that it doesn't create a copy of the class and pass the copy to the function? Why would you have it return a reference to the class as in example 1? I...
0
1148
by: Leszek Taratuta | last post by:
Hello, I have the following code snippet that overloads the "-" operator: // unary public static Vector operator -( Vector v ) { return new Vector( -v.X, -v.Y ); }
5
3632
by: Jerry Fleming | last post by:
As I am newbie to C++, I am confused by the overloading issues. Everyone says that the four operators can only be overloaded with class member functions instead of global (friend) functions: (), , ->, =. I wonder why there is such a restriction. Some tutorials say that 'new' and 'delete' can only be overloaded with static member functions, others say that all overloading function should be non-static. Then what is the fact, and why? ...
6
2590
by: Matthew Cook | last post by:
I would like to overload the unary minus operator so that I can negate an instance of a class and pass that instance to a function without creating an explicit temporary variable. Here is an example: #include <iostream> using namespace std; class Object { public:
19
2304
by: Jess | last post by:
Hello, After seeing some examples about operator overloading, I'm still a bit confused about the general syntax. The following is what I think, not sure whether it's correct. 1. For a unary operator that's a member of a class, its form is usually "operatorP()" (where P is the operator's name).
8
2977
by: Wayne Shu | last post by:
Hi everyone, I am reading B.S. 's TC++PL (special edition). When I read chapter 11 Operator Overloading, I have two questions. 1. In subsection 11.2.2 paragraph 1, B.S. wrote "In particular, operator =, operator, operator(), and operator-must be nonstatic member function; this ensures that their first operands will be lvalues". I know that these operators must be nonstatic member functions, but why this ensure their first operands will...
2
2950
by: jimzat | last post by:
I am trying to simulate the execution of some PLC ladder logic in python. I manually modified the rungs and executed this within python as a proof of concept, but I'd like to be able to skip the modification step. My thought was that this might be able to be completed via overloading, but I am not sure if (or how) it could be done. overloadings: + ==OR
1
4460
by: haderika | last post by:
Hey, I'm having trouble overloading the ~ operator (the determinant of the matrix) in a case of 2x2 matrices. So i have a matrix class, with the constructor, overloading +, += and ~ operators. the first two are working but I don't know how to overload the ~ one. here's what I have: matrix matrix::operator~(matrix &m) { double x; x=(m.a11*m.a22)-(m.a12*m.a21); return x; of course it's not working cause i can't return a double value...
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9030
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.