469,927 Members | 1,916 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Object and New (Basic)

Hi

See this,

Public Class Elan
Public variable as Interger
Public Sub Function1()
----------
------
End Sub

Public Sub Function1()
-----
--------
End Sub
End Class
I used this class in my Web page . Like

Dim Object1 as Elan

So it's gives Error

Dim Object1 as New Elan()

Here, What is the use of New ? , B'se I have no New Mothed in this Class.
----------------------------------------------------------------------------
----
and Why we use the Dataset Oject Like this

Dim objDataSet as DataSet

Why we not use the New Monthed here?
By,
Elankathir



Nov 18 '05 #1
2 1123
All reference types (classes) must be instantiated in order to be used.
This is why you couldn't use your class until you made a new instance of it.
Even if you don't explicitly create a constructor method ("New") for you
class, the CLR will create one for you in memory.

With other classes, you can use shared members, which means that you don't
have to have an instance of the class to use the member. The "show" method
of the MessageBox class is an example of this. You don't need to create an
instance of the MessageBox to use it.

With a DataSet (or any other class) you can DECLARE it:

Dim ds as DataSet

But you won't be able to do anything with it unless you create an instance
of it or set it equal to instance of another object.
"ElanKathir" <sn**********@hotmail.com> wrote in message
news:O3**************@TK2MSFTNGP11.phx.gbl...
Hi

See this,

Public Class Elan
Public variable as Interger
Public Sub Function1()
----------
------
End Sub

Public Sub Function1()
-----
--------
End Sub
End Class
I used this class in my Web page . Like

Dim Object1 as Elan

So it's gives Error

Dim Object1 as New Elan()

Here, What is the use of New ? , B'se I have no New Mothed in this Class.
-------------------------------------------------------------------------- -- ----
and Why we use the Dataset Oject Like this

Dim objDataSet as DataSet

Why we not use the New Monthed here?
By,
Elankathir


Nov 18 '05 #2

Hi Scott M.

Thanks for you Reply, I got this b'se of u. Thanks a lot..

Thanks & Regrads,
Elankathir
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Aussie Rules | last post: by
9 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.