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

Curious about VB.Net Syntax

I was curious if there is some reason why you don't need the "then" in the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then" as
part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned anywhere
before.

Just curious.

Thanks,

Tom
Nov 19 '05 #1
7 1216
Probably became optional because it wasn't necessary for the parser. VB is
so verbose as is, I guess they figured no need to make it required.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I was curious if there is some reason why you don't need the "then" in the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then"
as part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere before.

Just curious.

Thanks,

Tom

Nov 19 '05 #2
"Then" is indeed required for VB.NET in Visual Studio 2003.
Are you using something else? If so, what?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I was curious if there is some reason why you don't need the "then" in the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then"
as part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere before.

Just curious.

Thanks,

Tom

Nov 19 '05 #3
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:O4**************@TK2MSFTNGP12.phx.gbl...
"Then" is indeed required for VB.NET in Visual Studio 2003.
Are you using something else? If so, what?
It might be in VB.Net and Visual Studio 2003, but if you leave it out in
your asp.net pages (in my case I am using DW) that is not created by VS, it
works fine.

I assume that VS will catch it when trying to compile it, but ASP.Net
apparently lets it go through and knows that there is supposed to be a
"Then" there.

I was curious if it was a VB.Net or ASP.Net anomaly (and why). Apparently,
it is an ASP.NET anomaly.

Tom
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I was curious if there is some reason why you don't need the "then" in the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then"
as part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere before.

Just curious.

Thanks,

Tom


Nov 19 '05 #4
The "Then" is indeed entirely optional, whether you're coding in ASP.NET or
not.

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"tshad" wrote:
I was curious if there is some reason why you don't need the "then" in the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then" as
part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned anywhere
before.

Just curious.

Thanks,

Tom

Nov 19 '05 #5
"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
The "Then" is indeed entirely optional, whether you're coding in ASP.NET
or
not.
My question would be - why?

I really don't care whether they have the "then" there or not. I am
confused as to why they wouldn't just leave it as VB always was, instead of
starting to change things that don't need to be changed. I do like some of
the changes, I am just confused as to the logic of having either way.

Tom
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"tshad" wrote:
I was curious if there is some reason why you don't need the "then" in
the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then"
as
part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere
before.

Just curious.

Thanks,

Tom

Nov 19 '05 #6
Having an excessive number of alternatives is one of the hallmarks of VB.

For example:
1. Two radically different ways of wiring event handlers.
2. Numerous styles of declaring and initializing arrays (too many to list
here).
3. Two radically different ways of setting function return values
(assignment to function name or via the return statement).
4. Two radically different ways of handling exceptions.
5. "Case" in "Select Case" is optional.
6. "ByVal" is optional (i.e., parameters are ByVal if the modifier is
omitted).

and this is just off the top of my head...

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"tshad" wrote:
"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
The "Then" is indeed entirely optional, whether you're coding in ASP.NET
or
not.


My question would be - why?

I really don't care whether they have the "then" there or not. I am
confused as to why they wouldn't just leave it as VB always was, instead of
starting to change things that don't need to be changed. I do like some of
the changes, I am just confused as to the logic of having either way.

Tom

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"tshad" wrote:
I was curious if there is some reason why you don't need the "then" in
the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word "then"
as
part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere
before.

Just curious.

Thanks,

Tom


Nov 19 '05 #7
> My question would be - why?

I really don't care whether they have the "then" there or not. I am
confused as to why they wouldn't just leave it as VB always was, instead
of starting to change things that don't need to be changed. I do like
some of the changes, I am just confused as to the logic of having either
way.
Solution to your confusion: Pretend you never heard of any changes, and code
like you're used to.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eI**************@TK2MSFTNGP09.phx.gbl... "David Anton" <Da********@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
The "Then" is indeed entirely optional, whether you're coding in ASP.NET
or
not.


My question would be - why?

I really don't care whether they have the "then" there or not. I am
confused as to why they wouldn't just leave it as VB always was, instead
of starting to change things that don't need to be changed. I do like
some of the changes, I am just confused as to the logic of having either
way.

Tom

David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"tshad" wrote:
I was curious if there is some reason why you don't need the "then" in
the
if test of VB.Net or is it just ASP.NET.

I just noticed that I don't really need to explicitly put the word
"then" as
part of my if statement.

For example:

if a = b
b= 10
end if

works just as well as

if a = b then
b = 10
end if.

That used to give an error.

Is there some reason this has changed? I haven't seen it mentioned
anywhere
before.

Just curious.

Thanks,

Tom


Nov 19 '05 #8

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

Similar topics

3
by: Randell D. | last post by:
Folks, A ng poster recently questioned their usage/creation of arrays and their correct syntax. I got the idea to performance test from a recent (excellent) PHP Tutorial article that was in Linux...
4
by: badbetty | last post by:
Hello and thank you for reading on (hopefully). How does one typecast the XMLREADER returned from the XSLTRANSFORM method 'transform' into XMLTEXTREADER, so it can be passed in to an...
40
by: Confused User | last post by:
I am curious what the origins of size_t are. I see that it is usually typedef'd to be the native integer size of a particular machine. I also see that routines like strncpy(char *t, const char *s,...
3
by: CoreyWhite | last post by:
I wrote a program that shows some incredibly curious probabilities. It is a simple game where you guess a number between 0 and 2 that the computer thinks up. What is origonal about this game is...
4
by: Lance | last post by:
Hi all, I'm curious as to the technicalities of why a particular method declaring and calling is faster than the other. The C syntax is: \\\\\ BOOL PathMatchSpec( LPCSTR pszFile, LPCSTR...
15
by: Jim B. Wilson | last post by:
Am I nuts? Or only profoundly confused? I expected the this little script to print "0": class foo(int): def __init__(self, value): self = value & 0xF print foo(0x10) Instead, it prints...
34
by: chandu | last post by:
Hello every body , upto now i saw advantages of C# only,i am curious about what are the disadvantages of C#..(because any programming language should have some positives and negatives..) Thanks...
0
by: moo | last post by:
I'm trying to Sort the contents of a ListBox on an ASP.NET page, and not knowing the available options or syntax I went to MSDN, looked up Listbox, and found it had a Sort() method. No problem, so...
11
by: Liz | last post by:
anyone have any idea why there have been (at least) 82 VS 2008 post-release messages here on the C# board but only 5 on the VB.NET board; are the VB crowd just not interested?? strikes me as a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.