Object and New (Basic)

E

ElanKathir

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
 
S

Scott M.

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.
 
E

ElanKathir .S.N

Hi Scott M.

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

Thanks & Regrads,
Elankathir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top