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

VB equivalent of this C# code

what is vb equiv. of

++

shown in C# ?
Oct 16 '06 #1
6 2009
i ++ in VB is i += 1 or i = i + 1
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"Jon Paal" wrote:
what is vb equiv. of

++

shown in C# ?
Oct 16 '06 #2

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
what is vb equiv. of

++

shown in C# ?
David's answer is correct, but with the ++ (increment) and -- (decrement)
operators, you also need to be aware that the ++ and -- operators each come
in two versions, prefix and postfix, that affect operation in complex
expressions.

int i = 5;
i++; and
++i; do exactly the same thing, add 1 to the current value in the variable
i.

i--; and
--i; also do exactly the same thing, subtract 1 from the current value in i.

So, prefix vs. postfix notation makes no difference in simple expressions.

In an expression like this, however,

Assume i == 5
if (i++ 5) vs. if(++1 5).

there is a difference:
if(i++ 5) evaluates the Boolean expression based on the *current* value in
i, then adds 1 to i.
The Boolean expression is false.

if(++1 5) *first* adds 1 to i, then evaluates the Boolean expression using
the new value in i.
The Boolean expression is true.

As you didn't show the context in which you encountered the ++ in C# code, I
though you should be aware of the difference between prefix and postfix
notation.
Oct 17 '06 #3
So when you take it all into consideration, there is no single statement
equivalent to statements containing ++ or --, since VB doesn't allow
assignments within expressions (there is a complex multi-statement equivalent
however). There is only a single statement equivalent for simple "i++" or
"i--" statements.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: VB to Python converter
"pvdg42" wrote:
>
"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comwrote in message
news:ef**************@TK2MSFTNGP04.phx.gbl...
what is vb equiv. of

++

shown in C# ?
David's answer is correct, but with the ++ (increment) and -- (decrement)
operators, you also need to be aware that the ++ and -- operators each come
in two versions, prefix and postfix, that affect operation in complex
expressions.

int i = 5;
i++; and
++i; do exactly the same thing, add 1 to the current value in the variable
i.

i--; and
--i; also do exactly the same thing, subtract 1 from the current value in i.

So, prefix vs. postfix notation makes no difference in simple expressions.

In an expression like this, however,

Assume i == 5
if (i++ 5) vs. if(++1 5).

there is a difference:
if(i++ 5) evaluates the Boolean expression based on the *current* value in
i, then adds 1 to i.
The Boolean expression is false.

if(++1 5) *first* adds 1 to i, then evaluates the Boolean expression using
the new value in i.
The Boolean expression is true.

As you didn't show the context in which you encountered the ++ in C# code, I
though you should be aware of the difference between prefix and postfix
notation.
Oct 17 '06 #4
Jon,

I know it only on one place and that is in a "for index".

step 1

Cor

"Jon Paal" <Jon[ nospam ]Paal @ everywhere dot comschreef in bericht
news:ef**************@TK2MSFTNGP04.phx.gbl...
what is vb equiv. of

++

shown in C# ?

Oct 17 '06 #5
c#code :

if (failureCount++ >= MaxInvalidPasswordAttempts) {...

source of c# is example here:

http://www.eggheadcafe.com/articles/20051119.asp
Oct 19 '06 #6
David Anton wrote:
So when you take it all into consideration, there is no single statement
equivalent to statements containing ++ or --, since VB doesn't allow
assignments within expressions (there is a complex multi-statement equivalent
however). There is only a single statement equivalent for simple "i++" or
"i--" statements.
Well, if you *really*, *really* want it, nothing but common sense
forbids you from having:

<air-code>
Function PreInc(ByRef Value As Integer) As Integer
Value +=1
Return Value
End Function

Function PostInc(ByRef Value As Integer) As Integer
Dim Result As Integer = Value
Value +=1
Return Result
End Function

Function PreDec(ByRef Value As Integer) As Integer
Value -=1
Return Value
End Function

Function PostDec(ByRef Value As Integer) As Integer
Dim Result As Integer = Value
Value -=1
Return Result
End Function
</air-code>

Regards,

Branco.

Oct 19 '06 #7

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

Similar topics

1
by: Edward WIJAYA | last post by:
Hi, I am new to Python, and I like to learn more about it. Since I am used to Perl before, I would like to know what is Python equivalent of Perl code below: $filename = $ARGV;
4
by: Hai Nguyen | last post by:
I'm learning C sharp and do not like vb much. I'm creatiing a wepage using panel to test myself. I tried to use these code below, which is written in VB, and to transform them to c sharp but I got...
8
by: Xucyr | last post by:
I can't find any "short" code to make this work without taking 100s of lines (because I have to keep repeating this process several times). But this is what I have so far: int i = 7; do {...
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
48
by: Daniel Crespo | last post by:
Hi! I would like to know how can I do the PHP ternary operator/statement (... ? ... : ...) in Python... I want to something like: a = {'Huge': (quantity>90) ? True : False} Any...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
2
by: ghe | last post by:
Good day to all, Does anyone here know how to convert the specified Oracle code below into PHP? Oracle Code: TYPE myTable IS TABLE OF varchar2(1) INDEX BY BINARY_INTEGER; If the Oracle code i...
22
by: Kurien Mathew | last post by:
Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.