Dim obj As New Class crt Dim Obj As Class = New Class 
Author Message
 Dim obj As New Class crt Dim Obj As Class = New Class

Just to make sure - is this

Dim obj As New Class

the same as this

Dim Obj As Class = New Class

Last line is like its done in C# right?

Thanks



Thu, 23 Jun 2005 02:26:25 GMT  
 Dim obj As New Class crt Dim Obj As Class = New Class
You've got it almost right. You need "()" at the end of
new class.
Per O'Reilly's book on VB.net Languages, object variables
can be declared in several ways:
  Dim obj As New MyClass()
or:
  Dim obj As MyClass = New MyClass()
or:
  Dim obj As MyClass
  obj = New MyClass()
Quote:
>-----Original Message-----
>Just to make sure - is this

>Dim obj As New Class

>the same as this

>Dim Obj As Class = New Class

>Last line is like its done in C# right?

>Thanks



Thu, 23 Jun 2005 02:41:35 GMT  
 Dim obj As New Class crt Dim Obj As Class = New Class
Ron,

Quote:
>You've got it almost right. You need "()" at the end of
>new class.

No you don't. The parentheses are optional if you use the default
constructor.

The two statements Torben wrote do indeed give the same result.

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Thu, 23 Jun 2005 09:15:50 GMT  
 Dim obj As New Class crt Dim Obj As Class = New Class
Mattias,

This is VB .NET we are talking about, yes?  I already explained the why for
on this in another thread to the same guy.  The parenthesis get added
whether or not you type them, Unless you have intellisense turned off or
your using some other editor to do your code.

Either way you do not have to worry about typing them.

Cheers

Randy


Quote:
> Ron,

> >You've got it almost right. You need "()" at the end of
> >new class.

> No you don't. The parentheses are optional if you use the default
> constructor.

> The two statements Torben wrote do indeed give the same result.

> Mattias

> ===

> http://www.msjogren.net/dotnet/
> Please reply only to the newsgroup.



Thu, 23 Jun 2005 11:46:47 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Determine Obj Name on Class Initialisation

2. cant create obj error when calling a function in same class

3. dim and creating obj variables the right way?

4. Difference Between Dim and Private in a Class

5. VB4: Dim db as Database error in Class module

6. Arrays dim'd at class scope get type mismatch

7. derive class from protected class in base class

8. redundant New: Dim rs As New ADODB.Recordset

9. Dim as New vs. Set = New

10. Process to replace old COM obj with new

11. set obj = new Timer ??

12. Obj Ref not set to an instance of an Obj

 

 
Powered by phpBB® Forum Software