By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,669 Members | 1,654 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,669 IT Pros & Developers. It's quick & easy.

Case for variable names

P: n/a
I thought I read that the case for the variable names is important.

For example

Dim Wheel As Integer

Wheel here is a different variable from WHEEL.

Is this correct?

It doesn't seem to be in my code. In my code, I am changing WHEEL (just
for testing)many times and displaying Wheel. Wheel is always correct.
I would have assumed that Wheel would have been 0, since I only changed
WHEEL - if case is important.

Also, if you define a variable, does it get initialized?

For example

"Dim Wheel As Integer" is initialized to 0 and "Dim firstName As String"
is initialized to "".

Thanks,

Tom

Nov 20 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Thomas,
I thought I read that the case for the variable names is important. VB.NET is case insensitive: Wheel, wheel and WHEEL within one routine are
all the same identifier.

C# is case sensitive: Wheel, wheel and WHEEL within one routine all unique
identifiers.
Dim Wheel As Integer
Wheel here is a different variable from WHEEL.
Is this correct? No.
Also, if you define a variable, does it get initialized? Yes with the "default value" for that type.
"Dim Wheel As Integer" is initialized to 0 Correct the "default" value for Integer is a 0.
and "Dim firstName As String" is initialized to "". Incorrect, String is a reference type, the default value for reference
types, including string, is Nothing. However VB.NET treats a string that is
Nothing the same as "" in most cases. However calling an actually method of
firstName when its Nothing will fail!

Dim firstName As String
Debug.WriteLine(firstName.Length())

Will cause a NullReferenceException, as firstName contains Nothing.

However, the following succeeds:

Dim firstName As String
Debug.WriteLine(firstName = "")
If I want or need string variables to contain "", I will explicitly
initialize them with "" or String.Empty.

Dim firstName As String = ""

Hope this helps
Jay

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com... I thought I read that the case for the variable names is important.

For example

Dim Wheel As Integer

Wheel here is a different variable from WHEEL.

Is this correct?

It doesn't seem to be in my code. In my code, I am changing WHEEL (just
for testing)many times and displaying Wheel. Wheel is always correct.
I would have assumed that Wheel would have been 0, since I only changed
WHEEL - if case is important.

Also, if you define a variable, does it get initialized?

For example

"Dim Wheel As Integer" is initialized to 0 and "Dim firstName As String"
is initialized to "".

Thanks,

Tom

Nov 20 '05 #2

P: n/a
Cor
Hi Thomas,

I saw you are busy with webpages.
I thought I read that the case for the variable names is important.


Not with the language from VB (By instance for the ado.net variable names
between quotes it is)

The taste is different but for most people who uses VB that is an important
advantage from VB on other languages, VB find the propercase itself.

I hope this makes it clear?

Cor

Nov 20 '05 #3

P: n/a
Cor
Hi Tom,

In addition to Jay, because I saw you are busy with Webpages.

J++, Java, JavaScript, C++, C# and C are all case sensitive.
(It are all from C derived languages)

Cor
Nov 20 '05 #4

P: n/a
* Thomas Scheiderich <tf*@deltanet.com> scripsit:
Dim Wheel As Integer

Wheel here is a different variable from WHEEL.

Is this correct? No, Visual Basic isn't case sensitive, so the variable 'wheel' is the
same as 'Wheel' and 'WHEEL'.
Also, if you define a variable, does it get initialized?


Yes, it gets initialized with its default value, 'Nothing' for reference
types and the default value for value types (0 for numeric types, "" for
strings etc.).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

P: n/a
Herfried,
types and the default value for value types (0 for numeric types, "" for
strings etc.). Strings are initialized to Nothing, not "".

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c0*************@ID-208219.news.uni-berlin.de... * Thomas Scheiderich <tf*@deltanet.com> scripsit:
Dim Wheel As Integer

Wheel here is a different variable from WHEEL.

Is this correct?

No, Visual Basic isn't case sensitive, so the variable 'wheel' is the
same as 'Wheel' and 'WHEEL'.
Also, if you define a variable, does it get initialized?


Yes, it gets initialized with its default value, 'Nothing' for reference
types and the default value for value types (0 for numeric types, "" for
strings etc.).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #6

P: n/a
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
Strings are initialized to Nothing, not "".


Ooops. You are right!

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

P: n/a
Cor wrote:
Hi Tom,

In addition to Jay, because I saw you are busy with Webpages.

J++, Java, JavaScript, C++, C# and C are all case sensitive.
(It are all from C derived languages)
So the only language not case sensitive is VB and VB.NET?

Thanks,

Tom.

Cor


Nov 20 '05 #8

P: n/a
Thomas,
So the only language not case sensitive is VB and VB.NET?
If you're counting language, RPG & COBOL are not case sensitive also.

And yes! there are RPG & COBOL compilers for .NET!

Hope this helps
Jay

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com... Cor wrote:
Hi Tom,

In addition to Jay, because I saw you are busy with Webpages.

J++, Java, JavaScript, C++, C# and C are all case sensitive.
(It are all from C derived languages)

So the only language not case sensitive is VB and VB.NET?

Thanks,

Tom.

Cor

Nov 20 '05 #9

P: n/a
And Pascal isn't case sensitive and there is/are .net versions.

Tom

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
Thomas,
So the only language not case sensitive is VB and VB.NET?


If you're counting language, RPG & COBOL are not case sensitive also.

And yes! there are RPG & COBOL compilers for .NET!

Hope this helps
Jay

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
Cor wrote:
Hi Tom,

In addition to Jay, because I saw you are busy with Webpages.

J++, Java, JavaScript, C++, C# and C are all case sensitive.
(It are all from C derived languages)

So the only language not case sensitive is VB and VB.NET?

Thanks,

Tom.

Cor


Nov 20 '05 #10

P: n/a
Jay B. Harlow [MVP - Outlook] wrote:
Thomas,
So the only language not case sensitive is VB and VB.NET?

If you're counting language, RPG & COBOL are not case sensitive also.

And yes! there are RPG & COBOL compilers for .NET!

Some languages just never die. :)

Tom.

Hope this helps
Jay

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
Cor wrote:

Hi Tom,

In addition to Jay, because I saw you are busy with Webpages.

J++, Java, JavaScript, C++, C# and C are all case sensitive.
(It are all from C derived languages)


So the only language not case sensitive is VB and VB.NET?

Thanks,

Tom.
Cor



Nov 20 '05 #11

P: n/a
Tom,
Yep. can't forget about good old Pascal...

Only reason I mentioned RPG & COBOL, is I have a gig on the side working
with RPG right now...

Jay

"Tom Leylan" <ge*@iamtiredofspam.com> wrote in message
news:uv****************@TK2MSFTNGP10.phx.gbl...
And Pascal isn't case sensitive and there is/are .net versions.

Tom

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:uz**************@TK2MSFTNGP10.phx.gbl...
Thomas,
So the only language not case sensitive is VB and VB.NET?


If you're counting language, RPG & COBOL are not case sensitive also.

And yes! there are RPG & COBOL compilers for .NET!

Hope this helps
Jay

"Thomas Scheiderich" <tf*@deltanet.com> wrote in message
news:40**************@deltanet.com...
Cor wrote:

> Hi Tom,
>
> In addition to Jay, because I saw you are busy with Webpages.
>
> J++, Java, JavaScript, C++, C# and C are all case sensitive.
> (It are all from C derived languages)
>
So the only language not case sensitive is VB and VB.NET?

Thanks,

Tom.
> Cor
>
>
>



Nov 20 '05 #12

P: n/a
Cor
Hi Jay,

You forgot to mention that when those language started only uppercases where
used and that that is long been a habbit.

But in those languages where also not things like SqlClient.SqlCommand or
the most terrible of all in my eyes the Document Object Model, in which the
uppercases are for me unpredictable.

And therefore I hate case sensetive now.

:-)

Cor

Nov 20 '05 #13

P: n/a
Tom,

* "Tom Leylan" <ge*@iamtiredofspam.com> scripsit:
And Pascal isn't case sensitive and there is/are .net versions.


Delphi is case sensitive (AFAIR) and there is a .NET version.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #14

P: n/a
Delphi is case-insensitive (AFAIR) ... my copy is anyway...

I know there is at least one .Net version of Pascal I believe there are a
few implementations.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c0*************@ID-208219.news.uni-berlin.de...
Tom,

* "Tom Leylan" <ge*@iamtiredofspam.com> scripsit:
And Pascal isn't case sensitive and there is/are .net versions.


Delphi is case sensitive (AFAIR) and there is a .NET version.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #15

P: n/a
Tom,

* "Tom Leylan" <ge*@iamtiredofspam.com> scripsit:
Delphi is case-insensitive (AFAIR) ... my copy is anyway...


Thank you. In the meantime, I had a look at the documentation and
Delphi is case insensitive too. It seems that I thought about Modula-2,
which was case sensitive (and very similar to Pascal).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.