|
-
Mar 20th, 2006, 04:16 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Variables
is it correct to declare variables like this in Vb.NET ?:
Dim a, b, c as integer
or it should be:
Dim a as integer
dim b as integer
dim c as integer
Cuz i read somewhere that if i declare "Dim a, b, c as integer" then only c will be treat as integer , a and b are variants.
-
Mar 20th, 2006, 04:50 PM
#2
New Member
Re: Variables
Variant isn't supported in .net - it's been replaced by object - defining variables like that is fine - in your example all are integers.
-
Mar 20th, 2006, 04:58 PM
#3
Re: Variables
what you read was probably about VB6, when the
Dim a, b, c as integer, resulted in a and b being variants...
As gordon freeman mentioned, they have changed this for .NET
-
Mar 20th, 2006, 06:47 PM
#4
Re: Variables
As has been said, there is no technical issue with declaring multiple variables on a single line. In fact, you can even do this:
VB Code:
Dim x As String, y As Integer, z As Boolean
Having said that, it is generally considered better practice to declare each variable on a different line, regardless of whether they are the same type or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|